changeset 11017:a55e83bbf059

8132850: java.lang.ArrayIndexOutOfBoundsException during text rendering with many fonts installed Reviewed-by: jgodinez, serb
author aivanov
date Thu, 20 Aug 2015 15:38:12 +0300
parents 6fdaa740c72f
children 785f62105307
files src/share/classes/sun/font/CompositeFont.java src/share/classes/sun/font/FileFontStrike.java src/solaris/native/sun/awt/fontpath.c
diffstat 3 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/font/CompositeFont.java	Thu Aug 20 15:10:50 2015 +0300
+++ b/src/share/classes/sun/font/CompositeFont.java	Thu Aug 20 15:38:12 2015 +0300
@@ -71,6 +71,13 @@
         } else {
             numSlots = componentNames.length;
         }
+        /* We will limit the number of slots to 254.
+         * We store the slot for a glyph id in a byte and we may use one slot
+         * for an EUDC font, and we may also create a composite
+         * using this composite as a backup for a physical font.
+         * So we want to leave space for the two additional slots.
+         */
+         numSlots = (numSlots <= 254) ? numSlots : 254;
 
         /* Only the first "numMetricsSlots" slots are used for font metrics.
          * the rest are considered "fallback" slots".
--- a/src/share/classes/sun/font/FileFontStrike.java	Thu Aug 20 15:10:50 2015 +0300
+++ b/src/share/classes/sun/font/FileFontStrike.java	Thu Aug 20 15:38:12 2015 +0300
@@ -420,14 +420,13 @@
 
     /* The following method is called from CompositeStrike as a special case.
      */
-    private static final int SLOTZEROMAX = 0xffffff;
     int getSlot0GlyphImagePtrs(int[] glyphCodes, long[] images, int len) {
 
         int convertedCnt = 0;
 
         for (int i=0; i<len; i++) {
             int glyphCode = glyphCodes[i];
-            if (glyphCode >= SLOTZEROMAX) {
+            if (glyphCode >>> 24 != 0) {
                 return convertedCnt;
             } else {
                 convertedCnt++;
--- a/src/solaris/native/sun/awt/fontpath.c	Thu Aug 20 15:10:50 2015 +0300
+++ b/src/solaris/native/sun/awt/fontpath.c	Thu Aug 20 15:38:12 2015 +0300
@@ -1217,10 +1217,11 @@
                 minGlyphs = val;
             }
         }
+        FcCharSet *unionCharset = NULL;
         for (j=0; j<nfonts; j++) {
             FcPattern *fontPattern = fontset->fonts[j];
             FcChar8 *fontformat;
-            FcCharSet *unionCharset = NULL, *charset;
+            FcCharSet *charset = NULL;
 
             fontformat = NULL;
             (*FcPatternGetString)(fontPattern, FC_FONTFORMAT, 0, &fontformat);
@@ -1278,6 +1279,9 @@
             if (!includeFallbacks) {
                 break;
             }
+            if (fontCount == 254) {
+                break; // CompositeFont will only use up to 254 slots from here.
+            }
         }
 
         /* Once we get here 'fontCount' is the number of returned fonts