JDK-8233097 : Fontmetrics for large Fonts has zero width
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version:
    openjdk8u232,11.0.5,11.0.5-oracle,13.0.1,14 openjdk8u232,11.0.5,11.0.5-oracle,13.0.1,14
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2019-10-28
  • Updated: 2024-03-25
  • Resolved: 2019-11-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 13 JDK 14 Other
11.0.6-oracleFixed 13.0.2Fixed 14 b25Fixed openjdk8u272Fixed
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Occurs on Windows and Linux. MacOS seems to be OK.

A DESCRIPTION OF THE PROBLEM :
With the Java update 11.0.5 the font metrics returns a string width of zero for large font size objects. A correct width is only reported for space characters. We use the large font in large graphics transformations. Reporting the font metric for fonts with a fontsize up to 1950 seems to be OK. Fontsizes above 2000 return the unexpected result of a zero width.

REGRESSION : Last worked in version 11

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
13330.078125
3333.984375
ACTUAL -
0.0
3333.984375

---------- BEGIN SOURCE ----------
    public static void main( String[] args ) {
        Font font = new Font( "SansSerif", 0, 12000 );
        System.out.println( font.getStringBounds( "str", new FontRenderContext( null, false, true ) ).getWidth() );
        System.out.println( font.getStringBounds( " ", new FontRenderContext( null, false, true ) ).getWidth() );
    }

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use Java 11.04 instead 11.05.

FREQUENCY : always



Comments
openjdk8u232-b09: NOK ./openjdk-8u232-b09/bin/java FontMetricsTest 0.0 3814.453125 openjdk8u222-b10: OK ./openjdk-8u222-b10/bin/java FontMetricsTest 15890.625 3814.453125 Approving for OpenJDK 8u once [~alvdavi] adds the jdk8u-fix-request label.
12-08-2020

Fix request (8u) As reported here: https://mail.openjdk.java.net/pipermail/jdk8u-dev/2020-August/012386.html Problem affects openjdk8u too, starting with openjdk8u232. Patch applies cleanly.
11-08-2020

Fix request (11u) I would like to downport this for parity with 11.0.6-oracle. Applies clean.
21-11-2019

URL: https://hg.openjdk.java.net/jdk/jdk/rev/f5adbf111424 User: psadhukhan Date: 2019-11-21 09:06:33 +0000
21-11-2019

URL: https://hg.openjdk.java.net/jdk/client/rev/f5adbf111424 User: prr Date: 2019-11-04 18:05:14 +0000
04-11-2019

A fix has been proposed and reviewed which does as suggested above and as well as fixing the regression shows much better ( up to 10 x) performance for obtaining the metrics of such large fonts whilst still getting the same metrics as previously (when it was working). NB it is a separate issue that 11u and later metrics differ from JDK 8 and that isn't addressed here.
04-11-2019

Maybe we can just skip the rasterisation part ...
29-10-2019

https://bugs.openjdk.java.net/browse/JDK-8225286 limits the size of a glyph image to 1024 Not a problem since we don't use glyph rasterisation for large glyphs. However, getGlyphAdvance is needed whatever the size and it delegates to the rasterisation code (and then throws away the un-needed image). Ideally we should not need to get the image to get the advance but sometimes it is the best way to be sure of the effects of hinting on the advance. Also for the typical case we first ask for the image which returns the advance for free .. What we need to do is bypass using the image rasterisation path to get the advance for large point sizes. getGlyphMetrics has the same issue. Probably 100 pts as that's when we stop using the glyph image for drawing anyway.
29-10-2019

Reported against JDK 11.0.5, Font metrics returns a zero width string for large font size objects which is incorrect. Checked this with attached test case and could confirm the results. This seems to be failing with latest JDK 14 ea b20 as well. Results: ========= 8u231: OK 11.0.4: OK 11.0.5: Fail 12.0.2: OK 13: OK 13.0.1: Fail 14 ea b20: Fail To reproduce, run the attached test case with respective JDK versions. Run with JDK 14 ea b20 (Wrong Values): > java FontMetricsTest 0.0 3333.984375 Run with JDK 11.0.4 (Correct Values): > java FontMetricsTest 13330.078125 3333.984375
29-10-2019