-
Bug
-
Resolution: Fixed
-
P3
-
14, 17.0.5, 22, 23
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8334903 | 21.0.5-oracle | Philip Race | P3 | Resolved | Fixed | b01 |
JDK-8335157 | 21.0.5 | Martin Doerr | P3 | Resolved | Fixed | b01 |
JDK-8335109 | 17.0.13-oracle | Philip Race | P3 | Resolved | Fixed | b01 |
JDK-8335316 | 17.0.13 | Martin Doerr | P3 | Resolved | Fixed | b01 |
JDK-8335219 | 11.0.25-oracle | Philip Race | P3 | Resolved | Fixed | b01 |
Occurs on Windows and Linux.
A DESCRIPTION OF THE PROBLEM :
In Java 17.0.10 the font metrics returns a string width of zero for large font size. Moreover, every subsequent call for that font metrics with "normal" size will also return zero width, unless that size was requested before the "breaking" one.
Seems to be related to https://bugs.openjdk.org/browse/JDK-8233097
REGRESSION : Last worked in version 11
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Build and run the source code
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
size 12 width 58.02
size 100,000 width 24,744.094
size 7 width 33.845
size 8 width 38.68
size 9 width 43.515
size 10 width 48.35
size 11 width 53.185
size 12 width 58.02
size 14 width 67.689
size 16 width 77.359
size 18 width 87.029
size 20 width 96.699
size 24 width 116.039
ACTUAL -
size 12 width 58.02
size 100,000 width 0
size 7 width 0
size 8 width 0
size 9 width 0
size 10 width 0
size 11 width 0
size 12 width 58.02
size 14 width 0
size 16 width 0
size 18 width 0
size 20 width 0
size 24 width 0
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
String testString = "Test String";
Font font = new Font("SansSerif", Font.PLAIN, 12);
FontRenderContext frc = new FontRenderContext(null, false, true);
System.out.println(MessageFormat.format("size {0} width {1}", font.getSize(), font.getStringBounds(testString, frc).getWidth()));
// breaking size
font = font.deriveFont(100000f);
System.out.println(MessageFormat.format("size {0} width {1}", font.getSize(), font.getStringBounds(testString, frc).getWidth()));
float[] sizes = new float[] {7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 24};
for (float size: sizes) {
font = font.deriveFont(size);
System.out.println(MessageFormat.format("size {0} width {1}", font.getSize(), font.getStringBounds(testString, frc).getWidth()));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None, unless using JDK11 is an option
FREQUENCY : always
- backported by
-
JDK-8334903 Fontmetrics for large Fonts has zero width
- Resolved
-
JDK-8335109 Fontmetrics for large Fonts has zero width
- Resolved
-
JDK-8335157 Fontmetrics for large Fonts has zero width
- Resolved
-
JDK-8335219 Fontmetrics for large Fonts has zero width
- Resolved
-
JDK-8335316 Fontmetrics for large Fonts has zero width
- Resolved
- relates to
-
JDK-8233097 Fontmetrics for large Fonts has zero width
- Resolved
- links to
-
Commit openjdk/jdk17u-dev/acff32c3
-
Commit openjdk/jdk21u-dev/65cf18ae
-
Commit openjdk/jdk/25871af3
-
Review openjdk/jdk17u-dev/2640
-
Review openjdk/jdk21u-dev/792
-
Review openjdk/jdk/18703
-
Review(master) openjdk/jdk11u-dev/2826