-
Bug
-
Resolution: Fixed
-
P4
-
7
-
None
-
b43
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2188638 | OpenJDK6 | Igor Nekrestyanov | P3 | Resolved | Fixed | b19 |
Following test returns:
Exception in thread "main" java.lang.RuntimeException: Not equal:
<java.awt.geom.Rectangle2D$Float[x=5.78125,y=-47.796875,w=633.71484,h=57.515625]>
<java.awt.geom.Rectangle2D$Float[x=5.78125,y=0.0,w=633.71484,h=96.34375]>
at Test.testLineMeasurerBounds(Test.java:36)
at Test.main(Test.java:41)
While some difference between OpenJDK and Sun JDK is expected due to different font rasterizers used
it should not be that large.
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();
}
}
Exception in thread "main" java.lang.RuntimeException: Not equal:
<java.awt.geom.Rectangle2D$Float[x=5.78125,y=-47.796875,w=633.71484,h=57.515625]>
<java.awt.geom.Rectangle2D$Float[x=5.78125,y=0.0,w=633.71484,h=96.34375]>
at Test.testLineMeasurerBounds(Test.java:36)
at Test.main(Test.java:41)
While some difference between OpenJDK and Sun JDK is expected due to different font rasterizers used
it should not be that large.
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();
}
}
- backported by
-
JDK-2188638 OpenJDK: vertical text metrics may be significanly different from those returned by Sun JDK
-
- Resolved
-