Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8233097

Fontmetrics for large Fonts has zero width

XMLWordPrintable

    • 2d
    • b02
    • b25
    • x86_64
    • windows_10

        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


              prr Philip Race
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

                Created:
                Updated:
                Resolved: