[jsword-svn] r1176 - trunk/common-swing/src/main/java/org/crosswire/common/swing

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Thu Nov 2 21:17:21 MST 2006


Author: dmsmith
Date: 2006-11-02 21:17:16 -0700 (Thu, 02 Nov 2006)
New Revision: 1176

Modified:
   trunk/common-swing/src/main/java/org/crosswire/common/swing/FontChooser.java
Log:
Workaround for a Java bug from David Overcash.

Modified: trunk/common-swing/src/main/java/org/crosswire/common/swing/FontChooser.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/swing/FontChooser.java	2006-10-23 21:37:39 UTC (rev 1175)
+++ trunk/common-swing/src/main/java/org/crosswire/common/swing/FontChooser.java	2006-11-03 04:17:16 UTC (rev 1176)
@@ -250,12 +250,21 @@
         protected CustomComboBoxModel()
         {
             String[] names = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
-            // For older JDKs use: font_names = getToolkit().getFontList();
+
             fonts = new Font[names.length];
 
             for (int i = 0; i < fonts.length; i++)
             {
-                fonts[i] = new Font(names[i], Font.PLAIN, RENDERED_FONT_SIZE);
+                // We need to exclude certain fonts that cause the JVM to crash.
+                // See Bug Parade 6376296
+                // It will be fixed in Java 1.6 (Mustang)
+                if(names[i].equals("padmaa") || names[i].equals("Rekha") || names[i].indexOf("Lohit") > -1 || names[i].indexOf("aakar") > -1) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+                {
+                    continue;
+                }
+
+                // Add good fonts to total font listing
+                fonts[fontCount++] = new Font(names[i], Font.PLAIN, RENDERED_FONT_SIZE);
             }
         }
 
@@ -281,7 +290,7 @@
          */
         public int getSize()
         {
-            return fonts.length;
+            return fontCount;
         }
 
         /* (non-Javadoc)
@@ -293,8 +302,13 @@
         }
 
         /**
-         * An array of the fonts themselves
+         * The total number of fonts. Note, this may be less than or equal to fonts.length.
          */
+        private int fontCount;
+
+        /**
+         * An array of the fonts themselves. Note the array is as big as the total number of fonts in the system.
+         */
         private Font[] fonts;
 
         /**
@@ -329,7 +343,7 @@
             {
                 Font afont = (Font) value;
                 setText(afont.getFamily());
-                setFont(afont);
+                setFont(DEFAULT_FONT.getFont()); // afont); // Some fonts cannot display their own name.
             }
 
             return this;




More information about the jsword-svn mailing list