< prev index next >

src/java.desktop/share/classes/sun/font/SunFontManager.java

Print this page




1060                                  fontFormat, useJavaRasterizer, fontRank);
1061             }
1062         }
1063     }
1064 
1065     /*
1066      * This is the Physical font used when some other font on the system
1067      * can't be located. There has to be at least one font or the font
1068      * system is not useful and the graphics environment cannot sustain
1069      * the Java platform.
1070      */
1071     public PhysicalFont getDefaultPhysicalFont() {
1072         if (defaultPhysicalFont == null) {
1073             /* findFont2D will load all fonts before giving up the search.
1074              * If the JRE Lucida isn't found (eg because the JRE fonts
1075              * directory is missing), it could find another version of Lucida
1076              * from the host system. This is OK because at that point we are
1077              * trying to gracefully handle/recover from a system
1078              * misconfiguration and this is probably a reasonable substitution.
1079              */
1080             defaultPhysicalFont = (PhysicalFont)
1081                 findFont2D(getDefaultFontFaceName(), Font.PLAIN, NO_FALLBACK);



1082             if (defaultPhysicalFont == null) {
1083                 /* Because of the findFont2D call above, if we reach here, we
1084                  * know all fonts have already been loaded, just accept any
1085                  * match at this point. If this fails we are in real trouble
1086                  * and I don't know how to recover from there being absolutely
1087                  * no fonts anywhere on the system.
1088                  */
1089                 Iterator<PhysicalFont> i = physicalFonts.values().iterator();
1090                 if (i.hasNext()) {
1091                     defaultPhysicalFont = i.next();



1092                 } else {
1093                     throw new Error("Probable fatal error:No fonts found.");
1094                 }
1095             }
1096         }
1097         return defaultPhysicalFont;
1098     }
1099 
1100     public Font2D getDefaultLogicalFont(int style) {
1101         return findFont2D("dialog", style, NO_FALLBACK);
1102     }
1103 
1104     /*
1105      * return String representation of style prepended with "."
1106      * This is useful for performance to avoid unnecessary string operations.
1107      */
1108     private static String dotStyleStr(int num) {
1109         switch(num){
1110           case Font.BOLD:
1111             return ".bold";




1060                                  fontFormat, useJavaRasterizer, fontRank);
1061             }
1062         }
1063     }
1064 
1065     /*
1066      * This is the Physical font used when some other font on the system
1067      * can't be located. There has to be at least one font or the font
1068      * system is not useful and the graphics environment cannot sustain
1069      * the Java platform.
1070      */
1071     public PhysicalFont getDefaultPhysicalFont() {
1072         if (defaultPhysicalFont == null) {
1073             /* findFont2D will load all fonts before giving up the search.
1074              * If the JRE Lucida isn't found (eg because the JRE fonts
1075              * directory is missing), it could find another version of Lucida
1076              * from the host system. This is OK because at that point we are
1077              * trying to gracefully handle/recover from a system
1078              * misconfiguration and this is probably a reasonable substitution.
1079              */
1080             Font2D font2d =
1081                 findFont2D(getDefaultFontFaceName(), Font.PLAIN, NO_FALLBACK);
1082             if (font2d instanceof PhysicalFont) {
1083                 defaultPhysicalFont = (PhysicalFont) font2d;
1084             }
1085             if (defaultPhysicalFont == null) {
1086                 /* Because of the findFont2D call above, if we reach here, we
1087                  * know all fonts have already been loaded, just accept any
1088                  * match at this point. If this fails we are in real trouble
1089                  * and I don't know how to recover from there being absolutely
1090                  * no fonts anywhere on the system.
1091                  */
1092                 Iterator<PhysicalFont> i = physicalFonts.values().iterator();
1093                 if (i.hasNext()) {
1094                     defaultPhysicalFont = i.next();
1095                     if (font2d instanceof CompositeFont) {
1096                         defaultPhysicalFont = ((CompositeFont) font2d).getSlotFont(0);
1097                     }
1098                 } else {
1099                     throw new Error("Probable fatal error:No fonts found.");
1100                 }
1101             }
1102         }
1103         return defaultPhysicalFont;
1104     }
1105 
1106     public Font2D getDefaultLogicalFont(int style) {
1107         return findFont2D("dialog", style, NO_FALLBACK);
1108     }
1109 
1110     /*
1111      * return String representation of style prepended with "."
1112      * This is useful for performance to avoid unnecessary string operations.
1113      */
1114     private static String dotStyleStr(int num) {
1115         switch(num){
1116           case Font.BOLD:
1117             return ".bold";


< prev index next >