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

AWT java apps fail to start when some minimal fonts are present

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 7, 8, 9, 10
    • Fix Version/s: 10
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b31

      Description

      During initialisation of the fonts, there is a fixed number of fonts to retrieve that depends on the names defined in FontConfigManager.fontConfigNames.

      The native code asks fontconfig the best match for those fonts, but in certain cases, namely when only CFF fonts are installed fontconfig (even in addition to the minimum mandatory Type 1 ones), fontconfig returns the CFF as "best match".

      This happens, for example, when requesting a font of type "sans:regular:roman". CFF are valid fonts for fontconfig (and are effectively Type 1 OpenType fonts) so the match is registered, but then the actual set returned by fontconfig contains only CFF fonts that are then discarded, thus causing an array of 0 size for "sans:regular:roman", that later on causes an ArrayIndexOutOfBound when this array is accessed in java code:

      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
      at sun.font.CompositeStrike.getStrikeForSlot(CompositeStrike.java:75)
      at sun.font.CompositeStrike.getFontMetrics(CompositeStrike.java:93)
      at sun.font.FontDesignMetrics.initMatrixAndMetrics(FontDesignMetrics.java:359)
      at sun.font.FontDesignMetrics.<init>(FontDesignMetrics.java:350)
      at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:302)
      at sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1113)
      at javax.swing.JComponent.getFontMetrics(JComponent.java:1626)
      at ...

      On RHEL 7.4 for example, with STIX fonts and the following fonts:

      xorg-x11-fonts-Type1-7.5-9.el7.noarch
      stix-fonts-1.1.0-5.el7.noarch

      you can see what fc-match -f "sans:regular:roman" -sv returns, which is similar to what the code in the JDK does (output edited):

      Pattern has 34 elts (size 48)
      family: "STIX"(s)
      fontformat: "CFF"(w)
      postscriptname: "STIX-Regular"(w)

      Pattern has 34 elts (size 48)
      family: "Cantarell"(s)
      fontformat: "CFF"(w)
      postscriptname: "Cantarell-Regular"(w)

      Pattern has 34 elts (size 48)
      family: "STIX"(s)
      fontformat: "CFF"(w)
      postscriptname: "STIX-Bold"(w)

      Pattern has 34 elts (size 48)
      family: "STIX"(s)
      fontformat: "CFF"(w)
      postscriptname: "STIX-Italic"(w)

      Pattern has 34 elts (size 48)
      family: "STIX"(s)
      fontformat: "CFF"(w)
      postscriptname: "STIX-BoldItalic"(w)

        Activity

        neugens Mario Torre created issue -
        neugens Mario Torre made changes -
        Field Original Value New Value
        Assignee Mario Torre [ neugens ]
        neugens Mario Torre made changes -
        Description During initialisation of the fonts, there is a fixed number of fonts to retrieve that depends on the names defined in FontConfigManager.fontConfigNames.

        The native code asks fontconfig the best match for those fonts, but in certain cases, namely when only CFF fonts are installed fontconfig (even in addition to the minimum mandatory Type 1 ones), fontconfig returns the CFF as "best match".

        This happens, for example, when requesting a font of type "sans:regular:roman". CFF are valid fonts for fontconfig (and are effectively Type 1 OpenType fonts) so the match is registered, but then the actual set returned by fontconfig contains only CFF fonts that are then discarded, thus causing an array of 0 size for "sans:regular:roman", that later on causes an ArrayIndexOutOfBound when this array is accessed in java code:

        Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
        at sun.font.CompositeStrike.getStrikeForSlot(CompositeStrike.java:75)
        at sun.font.CompositeStrike.getFontMetrics(CompositeStrike.java:93)
        at sun.font.FontDesignMetrics.initMatrixAndMetrics(FontDesignMetrics.java:359)
        at sun.font.FontDesignMetrics.<init>(FontDesignMetrics.java:350)
        at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:302)
        at sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1113)
        at javax.swing.JComponent.getFontMetrics(JComponent.java:1626)
        at ...

        During initialisation of the fonts, there is a fixed number of fonts to retrieve that depends on the names defined in FontConfigManager.fontConfigNames.

        The native code asks fontconfig the best match for those fonts, but in certain cases, namely when only CFF fonts are installed fontconfig (even in addition to the minimum mandatory Type 1 ones), fontconfig returns the CFF as "best match".

        This happens, for example, when requesting a font of type "sans:regular:roman". CFF are valid fonts for fontconfig (and are effectively Type 1 OpenType fonts) so the match is registered, but then the actual set returned by fontconfig contains only CFF fonts that are then discarded, thus causing an array of 0 size for "sans:regular:roman", that later on causes an ArrayIndexOutOfBound when this array is accessed in java code:

        Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
        at sun.font.CompositeStrike.getStrikeForSlot(CompositeStrike.java:75)
        at sun.font.CompositeStrike.getFontMetrics(CompositeStrike.java:93)
        at sun.font.FontDesignMetrics.initMatrixAndMetrics(FontDesignMetrics.java:359)
        at sun.font.FontDesignMetrics.<init>(FontDesignMetrics.java:350)
        at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:302)
        at sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1113)
        at javax.swing.JComponent.getFontMetrics(JComponent.java:1626)
        at ...

        On RHEL 7.4 for example, with STIX fonts and the following fonts:

        xorg-x11-fonts-Type1-7.5-9.el7.noarch
        stix-fonts-1.1.0-5.el7.noarch

        you can see what fc-match -f "sans:regular:roman" -sv returns, which is similar to what the code in the JDK does (output edited):

        Pattern has 34 elts (size 48)
        family: "STIX"(s)
        fontformat: "CFF"(w)
        postscriptname: "STIX-Regular"(w)

        Pattern has 34 elts (size 48)
        family: "Cantarell"(s)
        fontformat: "CFF"(w)
        postscriptname: "Cantarell-Regular"(w)

        Pattern has 34 elts (size 48)
        family: "STIX"(s)
        fontformat: "CFF"(w)
        postscriptname: "STIX-Bold"(w)

        Pattern has 34 elts (size 48)
        family: "STIX"(s)
        fontformat: "CFF"(w)
        postscriptname: "STIX-Italic"(w)

        Pattern has 34 elts (size 48)
        family: "STIX"(s)
        fontformat: "CFF"(w)
        postscriptname: "STIX-BoldItalic"(w)
        neugens Mario Torre made changes -
        Affects Version/s 8 [ 11815 ]
        Affects Version/s 7 [ 11810 ]
        Affects Version/s 9 [ 14949 ]
        Affects Version/s 10 [ 16302 ]
        vdyakov Victor Dyakov made changes -
        Fix Version/s 10 [ 16302 ]
        andrew Andrew Hughes made changes -
        Status New [ 10000 ] Open [ 1 ]
        bvaidya Balchandra Vaidya made changes -
        Subcomponent java.awt [ 196 ]
        bvaidya Balchandra Vaidya made changes -
        Labels bugdb_26767156
        vdyakov Victor Dyakov made changes -
        Link This issue relates to JDK-8187811 [ JDK-8187811 ]
        hgupdate HG Updates made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolved In Build team [ 17324 ]
        Resolution Fixed [ 1 ]
        hgupdate HG Updates made changes -
        Resolved In Build team [ 17324 ] master [ 18256 ]
        hgupdate HG Updates made changes -
        Resolved In Build master [ 18256 ] b31 [ 17504 ]
        prr Philip Race made changes -
        Link This issue duplicates JDK-8187811 [ JDK-8187811 ]

          People

          • Assignee:
            neugens Mario Torre
            Reporter:
            neugens Mario Torre
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: