[OpenJDK 2D-Dev] openjdk incompatibility
Phil Race
Phil.Race at Sun.COM
Sat Oct 18 23:35:05 UTC 2008
You didn't show what the result was from OpenJDK
Seems the complaint here is the that the position of the vertical bounds
is suspect.
Looks like the sign is incorrect in some code that interfaces to
freetype and returns glyph bounds
I think bbox.yMax should be -bbox.yMax, since freetype considers the
top-most coord as
the max, and that needs to be converted to 2D's coordinate system.
So this appears to be a bug in openjdk.
-phil.
Hiroshi Yamauchi wrote:
> Hi,
>
> Here's a test that indicates an incompatibility between OpenJDK6/7 and
> Sun JDK. It passes on Sun JDK but not on OpenJDK. So, I believe this
> is due to the difference between the two font rasterizer
> implementations. The incompatibility causes a vertical position gap.
>
> Is this a new bug, a known bug, or an implementation difference? Is
> there a fix available?
>
> If this isn't a bug, how would you suggest changing existing
> applications that rely on the Sun JDK's behavior?
>
> Thanks,
> Hiroshi
>
>
> import java.awt.*;
> import java.awt.font.*;
> import java.awt.geom.*;
> import java.text.*;
> import java.io.File;
>
> public class OpenJDKFontTest {
>
> // Copy this ttf file from the Sun JDK
> public static final String PATH_TO_FONT = "./LucidaSansRegular.ttf";
> public static final String TEST_CONTENT = "Beds, carriers, bowls,
> leashes, snacks, and more.";
>
> public static void testLineMeasurerBounds() throws Exception {
> Font font = Font.createFont(Font.TRUETYPE_FONT, new
> File(PATH_TO_FONT)).deriveFont(62f);
>
> AttributedString attributedString = new AttributedString(TEST_CONTENT);
>
> attributedString.addAttribute(TextAttribute.FONT, font);
>
> AttributedCharacterIterator paragraph = attributedString.getIterator();
> int paragraphEnd = paragraph.getEndIndex();
>
> FontRenderContext frc = new FontRenderContext(null, true, true);
>
> LineBreakMeasurer lineMeasurer = new LineBreakMeasurer(paragraph, frc);
> lineMeasurer.setPosition(paragraph.getBeginIndex());
> float desiredWidth = 882f;
>
> TextLayout layout = lineMeasurer.nextLayout(desiredWidth,
> paragraphEnd, true);
>
> Rectangle2D textBox = layout.getBounds();
>
> Rectangle2D expected = new Rectangle2D.Float(5.78125f,
> -47.796875f, 633.71484f, 57.515625f);
>
> if (!expected.equals(textBox)) {
> throw new RuntimeException("Not equal: <" + expected + "> <" +
> textBox + ">");
> }
> }
>
> public static void main(String[] args) throws Exception {
> testLineMeasurerBounds();
> }
>
> }
>
More information about the 2d-dev
mailing list