< prev index next >

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

Print this page
rev 60064 : 8248802: Add log helper methods to FontUtilities.java

@@ -318,11 +318,11 @@
                             String name = br.readLine();
                             if (name == null) {
                                 break;
                             } else {
                                 if (FontUtilities.debugFonts()) {
-                                    FontUtilities.getLogger().warning("read bad font: " + name);
+                                    FontUtilities.logWarning("read bad font: " + name);
                                 }
                                 badFonts.add(name);
                             }
                         }
                     } catch (IOException e) {

@@ -352,11 +352,11 @@
                 fontConfig = createFontConfiguration();
 
                 String[] fontInfo = getDefaultPlatformFont();
                 defaultFontName = fontInfo[0];
                 if (defaultFontName == null && FontUtilities.debugFonts()) {
-                    FontUtilities.getLogger().warning("defaultFontName is null");
+                    FontUtilities.logWarning("defaultFontName is null");
                 }
                 defaultFontFileName = fontInfo[1];
 
                 String extraFontPath = fontConfig.getExtraFontPath();
 

@@ -401,14 +401,13 @@
                             dbgFontPath.substring("append:".length());
                     }
                 }
 
                 if (FontUtilities.debugFonts()) {
-                    PlatformLogger logger = FontUtilities.getLogger();
-                    logger.info("JRE font directory: " + jreFontDirName);
-                    logger.info("Extra font path: " + extraFontPath);
-                    logger.info("Debug font path: " + dbgFontPath);
+                    FontUtilities.logInfo("JRE font directory: " + jreFontDirName);
+                    FontUtilities.logInfo("Extra font path: " + extraFontPath);
+                    FontUtilities.logInfo("Debug font path: " + dbgFontPath);
                 }
 
                 if (dbgFontPath != null) {
                     /* In debugging mode we register all the paths
                      * Caution: this is a very expensive call on Solaris:-

@@ -560,14 +559,13 @@
         }
         altNameCache.put(compositeName.toLowerCase(Locale.ENGLISH), cf);
     }
 
     private void addCompositeToFontList(CompositeFont f, int rank) {
-
         if (FontUtilities.isLogging()) {
-            FontUtilities.getLogger().info("Add to Family "+ f.familyName +
-                        ", Font " + f.fullName + " rank="+rank);
+            FontUtilities.logInfo("Add to Family " + f.familyName +
+                        ", Font " + f.fullName + " rank=" + rank);
         }
         f.setRank(rank);
         compositeFonts.put(f.fullName, f);
         fullNameToFont.put(f.fullName.toLowerCase(Locale.ENGLISH), f);
 

@@ -623,12 +621,12 @@
             return null;
         }
         f.setRank(rank);
         if (!physicalFonts.containsKey(fontName)) {
             if (FontUtilities.isLogging()) {
-                FontUtilities.getLogger().info("Add to Family "+familyName +
-                            ", Font " + fontName + " rank="+rank);
+                FontUtilities.logInfo("Add to Family " + familyName +
+                            ", Font " + fontName + " rank=" + rank);
             }
             physicalFonts.put(fontName, f);
             FontFamily family = FontFamily.getFamily(familyName);
             if (family == null) {
                 family = new FontFamily(familyName, false, rank);

@@ -697,22 +695,19 @@
                  * In other words if we reach here, there's a possible
                  * problem with our choice of font configuration fonts.
                  */
                 if (oldFont.platName.startsWith(jreFontDirName)) {
                     if (FontUtilities.isLogging()) {
-                        FontUtilities.getLogger()
-                              .warning("Unexpected attempt to replace a JRE " +
-                                       " font " + fontName + " from " +
-                                        oldFont.platName +
+                        FontUtilities.logWarning("Unexpected attempt to replace a JRE " +
+                                       " font " + fontName + " from " + oldFont.platName +
                                        " with " + newFont.platName);
                     }
                     return oldFont;
                 }
 
                 if (FontUtilities.isLogging()) {
-                    FontUtilities.getLogger()
-                          .info("Replace in Family " + familyName +
+                    FontUtilities.logInfo("Replace in Family " + familyName +
                                 ",Font " + fontName + " new rank="+rank +
                                 " from " + oldFont.platName +
                                 " with " + newFont.platName);
                 }
                 replaceFont(oldFont, newFont);

@@ -901,12 +896,11 @@
 
         if (fileNameKey == null) {
             return null;
         }
         if (FontUtilities.isLogging()) {
-            FontUtilities.getLogger()
-                            .info("Opening deferred font file " + fileNameKey);
+            FontUtilities.logInfo("Opening deferred font file " + fileNameKey);
         }
 
         PhysicalFont physicalFont = null;
         FontRegistrationInfo regInfo = deferredFontFiles.get(fileNameKey);
         if (regInfo != null) {

@@ -989,18 +983,16 @@
                 break;
             default:
 
             }
             if (FontUtilities.isLogging()) {
-                FontUtilities.getLogger()
-                      .info("Registered file " + fileName + " as font " +
+                FontUtilities.logInfo("Registered file " + fileName + " as font " +
                             physicalFont + " rank="  + fontRank);
             }
         } catch (FontFormatException ffe) {
             if (FontUtilities.isLogging()) {
-                FontUtilities.getLogger().warning("Unusable font: " +
-                               fileName + " " + ffe.toString());
+                FontUtilities.logInfo("Unusable font: " + fileName + " " + ffe.toString());
             }
         }
         if (physicalFont != null &&
             fontFormat != FONTFORMAT_NATIVE) {
             registeredFonts.put(fileName, physicalFont);

@@ -1040,12 +1032,11 @@
             if (font2d != null) {
                 if (font2d instanceof PhysicalFont) {
                     defaultPhysicalFont = (PhysicalFont)font2d;
                 } else {
                     if (FontUtilities.isLogging()) {
-                        FontUtilities.getLogger()
-                            .warning("Font returned by findFont2D for default font name " +
+                        FontUtilities.logWarning("Font returned by findFont2D for default font name " +
                                      defaultFontName + " is not a physical font: " + font2d.getFontName(null));
                     }
                 }
             }
             if (defaultPhysicalFont == null) {

@@ -1302,12 +1293,11 @@
                             }
                         }
                     }
                     fontToFamilyNameMap.remove(name);
                     if (FontUtilities.isLogging()) {
-                        FontUtilities.getLogger()
-                                             .info("No file for font:" + name);
+                        FontUtilities.logInfo("No file for font:" + name);
                     }
                 }
             }
         }
     }

@@ -1353,12 +1343,11 @@
         HashMap<String,ArrayList<String>> familyToFontListMap2 = null;;
 
         for (String pathFile : getFontFilesFromPath(false)) {
             if (!registryFiles.contains(pathFile)) {
                 if (FontUtilities.isLogging()) {
-                    FontUtilities.getLogger()
-                                 .info("Found non-registry file : " + pathFile);
+                    FontUtilities.logInfo("Found non-registry file : " + pathFile);
                 }
                 PhysicalFont f = registerFontFile(getPathName(pathFile));
                 if (f == null) {
                     continue;
                 }

@@ -1398,23 +1387,21 @@
             try {
                 int fn = 0;
                 TrueTypeFont ttf;
                 String fullPath = getPathName(file);
                 if (FontUtilities.isLogging()) {
-                    FontUtilities.getLogger()
-                                   .info("Trying to resolve file " + fullPath);
+                    FontUtilities.logInfo("Trying to resolve file " + fullPath);
                 }
                 do {
                     ttf = new TrueTypeFont(fullPath, null, fn++, false);
                     //  prefer the font's locale name.
                     String fontName = ttf.getFontName(l).toLowerCase();
                     if (unmappedFonts.contains(fontName)) {
                         fontToFileMap.put(fontName, file);
                         unmappedFonts.remove(fontName);
                         if (FontUtilities.isLogging()) {
-                            FontUtilities.getLogger()
-                                  .info("Resolved absent registry entry for " +
+                            FontUtilities.logInfo("Resolved absent registry entry for " +
                                         fontName + " located in " + fullPath);
                         }
                     }
                 }
                 while (fn < ttf.getFontCount());

@@ -1536,12 +1523,11 @@
             }
         }
 
         if (failure) {
             if (FontUtilities.isLogging()) {
-                FontUtilities.getLogger().
-                    info("Hardcoded file missing looking for " + lcName);
+                FontUtilities.logInfo("Hardcoded file missing looking for " + lcName);
             }
             platformFontMap.remove(firstWord);
             return null;
         }
 

@@ -1564,12 +1550,11 @@
              }
          });
 
         if (failure) {
             if (FontUtilities.isLogging()) {
-                FontUtilities.getLogger().
-                    info("Hardcoded file missing looking for " + lcName);
+                FontUtilities.logInfo("Hardcoded file missing looking for " + lcName);
             }
             platformFontMap.remove(firstWord);
             return null;
         }
 

@@ -1832,12 +1817,11 @@
         for (int f=0;f<fontList.length;f++) {
             String fontNameLC = fontList[f].toLowerCase(Locale.ENGLISH);
             String fileName = fontToFileMap.get(fontNameLC);
             if (fileName == null) {
                 if (FontUtilities.isLogging()) {
-                    FontUtilities.getLogger()
-                          .info("Platform lookup : No file for font " +
+                    FontUtilities.logInfo("Platform lookup : No file for font " +
                                 fontList[f] + " in family " +familyName);
                 }
                 return null;
             }
         }

@@ -1903,13 +1887,12 @@
          */
         Font2D font = fontNameCache.get(mapName);
         if (font != null) {
             return font;
         }
-
         if (FontUtilities.isLogging()) {
-            FontUtilities.getLogger().info("Search for font: " + name);
+            FontUtilities.logInfo("Search for font: " + name);
         }
 
         // The check below is just so that the bitmap fonts being set by
         // AWT and Swing thru the desktop properties do not trigger the
         // the load fonts case. The two bitmap fonts are now mapped to

@@ -2019,13 +2002,13 @@
 
         if (FontUtilities.isWindows) {
 
             font = findFontFromPlatformMap(lowerCaseName, style);
             if (FontUtilities.isLogging()) {
-                FontUtilities.getLogger()
-                    .info("findFontFromPlatformMap returned " + font);
+                FontUtilities.logInfo("findFontFromPlatformMap returned " + font);
             }
+
             if (font != null) {
                 fontNameCache.put(mapName, font);
                 return font;
             }
             /* Don't want Windows to return a font from C:\Windows\Fonts

@@ -2040,12 +2023,11 @@
                 }
             }
             font = findFontFromPlatform(lowerCaseName, style);
             if (font != null) {
                 if (FontUtilities.isLogging()) {
-                    FontUtilities.getLogger()
-                          .info("Found font via platform API for request:\"" +
+                    FontUtilities.logInfo("Found font via platform API for request:\"" +
                                 name + "\":, style="+style+
                                 " found font: " + font);
                 }
                 fontNameCache.put(mapName, font);
                 return font;

@@ -2114,22 +2096,20 @@
         /* If reach here and no match has been located, then if all fonts
          * are not yet loaded, do so, and then recurse.
          */
         if (!loadedAllFonts) {
             if (FontUtilities.isLogging()) {
-                FontUtilities.getLogger()
-                                       .info("Load fonts looking for:" + name);
+                FontUtilities.logInfo("Load fonts looking for:" + name);
             }
             loadFonts();
             loadedAllFonts = true;
             return findFont2D(name, style, fallback);
         }
 
         if (!loadedAllFontFiles) {
             if (FontUtilities.isLogging()) {
-                FontUtilities.getLogger()
-                                  .info("Load font files looking for:" + name);
+                FontUtilities.logInfo("Load font files looking for:" + name);
             }
             loadFontFiles();
             loadedAllFontFiles = true;
             return findFont2D(name, style, fallback);
         }

@@ -2183,13 +2163,12 @@
         } else if (lowerCaseName.equals("courier")) {
             font = findFont2D("monospaced", style, fallback);
             fontNameCache.put(mapName, font);
             return font;
         }
-
         if (FontUtilities.isLogging()) {
-            FontUtilities.getLogger().info("No font found for:" + name);
+            FontUtilities.logInfo("No font found for:" + name);
         }
 
         switch (fallback) {
         case PHYSICAL_FALLBACK: return getDefaultPhysicalFont();
         case LOGICAL_FALLBACK: return getDefaultLogicalFont(style);

@@ -2360,12 +2339,11 @@
         if (!(font2D instanceof PhysicalFont)) {
             /* We should never reach here, but just in case */
             return;
         } else {
             if (FontUtilities.isLogging()) {
-                FontUtilities.getLogger()
-                                     .severe("Deregister bad font: " + font2D);
+                FontUtilities.logSevere("Deregister bad font: " + font2D);
             }
             replaceFont((PhysicalFont)font2D, getDefaultPhysicalFont());
         }
     }
 

@@ -2384,24 +2362,22 @@
         /* If we try to replace the font with itself, that won't work,
          * so pick any alternative physical font
          */
         if (oldFont == newFont) {
             if (FontUtilities.isLogging()) {
-                FontUtilities.getLogger()
-                      .severe("Can't replace bad font with itself " + oldFont);
+                FontUtilities.logSevere("Can't replace bad font with itself " + oldFont);
             }
             PhysicalFont[] physFonts = getPhysicalFonts();
             for (int i=0; i<physFonts.length;i++) {
                 if (physFonts[i] != newFont) {
                     newFont = physFonts[i];
                     break;
                 }
             }
             if (oldFont == newFont) {
                 if (FontUtilities.isLogging()) {
-                    FontUtilities.getLogger()
-                           .severe("This is bad. No good physicalFonts found.");
+                    FontUtilities.logSevere("This is bad. No good physicalFonts found.");
                 }
                 return;
             }
         }
 

@@ -2498,14 +2474,12 @@
      * almost never used. The main case in which it is called is when
      * a bogus font name is used and we need to check all possible names
      * before returning the default case.
      */
     private Font2D findFont2DAllLocales(String name, int style) {
-
         if (FontUtilities.isLogging()) {
-            FontUtilities.getLogger()
-                           .info("Searching localised font names for:" + name);
+            FontUtilities.logInfo("Searching localised font names for:" + name);
         }
 
         /* If reach here and no match has been located, then if we have
          * not yet built the map of localeFullNamesToFont for TT fonts, do so
          * now. This method must be called after all fonts have been loaded.

@@ -2637,13 +2611,13 @@
      * to use Mincho instead of Gothic for dialoginput in JA locales
      * on windows. Not needed on other platforms.
      */
     public synchronized void useAlternateFontforJALocales() {
         if (FontUtilities.isLogging()) {
-            FontUtilities.getLogger()
-                .info("Entered useAlternateFontforJALocales().");
+            FontUtilities.logInfo("Entered useAlternateFontforJALocales().");
         }
+
         if (!FontUtilities.isWindows) {
             return;
         }
         gAltJAFont = true;
     }

@@ -2652,12 +2626,13 @@
         return gAltJAFont;
     }
 
     public synchronized void preferLocaleFonts() {
         if (FontUtilities.isLogging()) {
-            FontUtilities.getLogger().info("Entered preferLocaleFonts().");
+            FontUtilities.logInfo("Entered preferLocaleFonts().");
         }
+
         /* Test if re-ordering will have any effect */
         if (!FontConfiguration.willReorderForStartupLocale()) {
             return;
         }
         if (gLocalePref == true) {

@@ -2668,13 +2643,13 @@
         _usingAlternateComposites = true;
     }
 
     public synchronized void preferProportionalFonts() {
         if (FontUtilities.isLogging()) {
-            FontUtilities.getLogger()
-                .info("Entered preferProportionalFonts().");
+            FontUtilities.logInfo("Entered preferProportionalFonts().");
         }
+
         /* If no proportional fonts are configured, there's no need
          * to take any action.
          */
         if (!FontConfiguration.hasMonoToPropMap()) {
             return;

@@ -2910,12 +2885,11 @@
                 continue;
             }
 
             if (badFonts != null && badFonts.contains(fullName)) {
                 if (FontUtilities.debugFonts()) {
-                    FontUtilities.getLogger()
-                                         .warning("skip bad font " + fullName);
+                    FontUtilities.logWarning("skip bad font " + fullName);
                 }
                 continue; // skip this font file.
             }
 
             registeredFontFiles.add(fullName);

@@ -2930,11 +2904,11 @@
                     message += " with native name(s) " + natNames[0];
                     for (int nn = 1; nn < natNames.length; nn++) {
                         message += ", " + natNames[nn];
                     }
                 }
-                FontUtilities.getLogger().info(message);
+                FontUtilities.logInfo(message);
             }
             fontNames[fontCount] = fullName;
             nativeNames[fontCount++] = getNativeNames(fullName, null);
         }
         registerFonts(fontNames, nativeNames, fontCount, fontFormat,

@@ -2980,12 +2954,11 @@
         }
         /* Use lock specific to the font system */
         synchronized (this) {
             if (FontUtilities.debugFonts()) {
                 Thread.dumpStack();
-                FontUtilities.getLogger()
-                            .info("SunGraphicsEnvironment.loadFonts() called");
+                FontUtilities.logInfo("SunGraphicsEnvironment.loadFonts() called");
             }
             initialiseDeferredFonts();
 
             AccessController.doPrivileged(new PrivilegedAction<Void>() {
                 public Void run() {

@@ -3099,11 +3072,11 @@
         }
         /* Use lock specific to the font system */
         synchronized (this) {
             if (FontUtilities.debugFonts()) {
                 Thread.dumpStack();
-                FontUtilities.getLogger().info("loadAllFontFiles() called");
+                FontUtilities.logInfo("loadAllFontFiles() called");
             }
             AccessController.doPrivileged(new PrivilegedAction<Void>() {
                 public Void run() {
                     if (fontPath == null) {
                         fontPath = getPlatformFontPath(noType1Font);

@@ -3131,14 +3104,12 @@
      * The composites themselves are then registered.
      */
     private void
         initCompositeFonts(FontConfiguration fontConfig,
                            ConcurrentHashMap<String, Font2D>  altNameCache) {
-
         if (FontUtilities.isLogging()) {
-            FontUtilities.getLogger()
-                            .info("Initialising composite fonts");
+            FontUtilities.logInfo("Initialising composite fonts");
         }
 
         int numCoreFonts = fontConfig.getNumberCoreFonts();
         String[] fcFonts = fontConfig.getPlatformFontNames();
         for (int f=0; f<fcFonts.length; f++) {

@@ -3234,12 +3205,11 @@
                                       descriptor.getExclusionRanges(),
                                       descriptor.getExclusionRangeLimits(),
                                       true);
             }
             if (FontUtilities.debugFonts()) {
-                FontUtilities.getLogger()
-                               .info("registered " + descriptor.getFaceName());
+                FontUtilities.logInfo("registered " + descriptor.getFaceName());
             }
         }
     }
 
     /**
< prev index next >