jdk/src/java.desktop/share/classes/sun/font/CompositeFont.java
changeset 39537 b2d4ed0ff6b9
parent 34399 7ea60f3aab93
child 43829 c1bfe62c318e
--- a/jdk/src/java.desktop/share/classes/sun/font/CompositeFont.java	Wed Jun 29 12:22:38 2016 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/font/CompositeFont.java	Wed Jun 29 11:38:29 2016 +0300
@@ -289,10 +289,21 @@
                 if (componentNames[slot] == null) {
                     componentNames[slot] = name;
                 } else if (!componentNames[slot].equalsIgnoreCase(name)) {
-                    components[slot] =
-                        (PhysicalFont) fm.findFont2D(componentNames[slot],
-                                                     style,
+                    /* If a component specifies the file with a bad font,
+                     * the corresponding slot will be initialized by
+                     * default physical font. In such case findFont2D may
+                     * return composite font which cannot be casted to
+                     * physical font.
+                     */
+                    try {
+                        components[slot] =
+                            (PhysicalFont) fm.findFont2D(componentNames[slot],
+                                                         style,
                                                 FontManager.PHYSICAL_FALLBACK);
+                    } catch (ClassCastException cce) {
+                        /* Assign default physical font to the slot */
+                        components[slot] = fm.getDefaultPhysicalFont();
+                    }
                 }
             }
             deferredInitialisation[slot] = false;