< prev index next >
src/java.desktop/share/classes/sun/font/SunFontManager.java
Print this page
rev 60042 : 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,15 +559,12 @@
}
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 +
+ 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);
FontFamily family = FontFamily.getFamily(f.familyName);
@@ -622,14 +618,12 @@
/* Don't register any font that has the same name as a composite */
return null;
}
f.setRank(rank);
if (!physicalFonts.containsKey(fontName)) {
- if (FontUtilities.isLogging()) {
- FontUtilities.getLogger().info("Add to Family "+familyName +
+ 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);
family.setFont(f, f.style);
@@ -696,27 +690,20 @@
* the host O/S version is for the use of AWT.
* 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);
physicalFonts.put(fontName, newFont);
fullNameToFont.put(fontName.toLowerCase(Locale.ENGLISH),
newFont);
@@ -900,14 +887,11 @@
PhysicalFont initialiseDeferredFont(String fileNameKey) {
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) {
deferredFontFiles.remove(fileNameKey);
@@ -988,20 +972,14 @@
physicalFont = addToFontList(nf, fontRank);
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);
}
@@ -1039,17 +1017,14 @@
Font2D font2d = findFont2D(defaultFontName, Font.PLAIN, NO_FALLBACK);
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) {
/* Because of the findFont2D call above, if we reach here, we
* know all fonts have already been loaded, just accept any
* match at this point. If this fails we are in real trouble
* and I don't know how to recover from there being absolutely
@@ -1301,14 +1276,11 @@
familyToFontListMap.remove(familyName);
}
}
}
fontToFamilyNameMap.remove(name);
- if (FontUtilities.isLogging()) {
- FontUtilities.getLogger()
- .info("No file for font:" + name);
- }
+ FontUtilities.logInfo("No file for font:" + name);
}
}
}
}
@@ -1352,14 +1324,11 @@
HashMap<String,String> fontToFamilyNameMap2 = null;
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;
}
if (fontToFileMap2 == null) {
@@ -1397,28 +1366,22 @@
for (String file : unmappedFiles) {
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());
} catch (Exception e) {
}
}
}
@@ -1535,14 +1498,11 @@
failure = true;
}
}
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;
}
/* Some of these may be null,as not all styles have to exist */
@@ -1563,14 +1523,11 @@
return Boolean.FALSE;
}
});
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;
}
/* If we reach here we know that we have all the files we
@@ -1831,15 +1788,12 @@
*/
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;
}
}
/* Currently this code only looks for TrueType fonts, so format
@@ -1904,13 +1858,11 @@
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
// appropriate equivalents for serif and sansserif.
@@ -2018,14 +1970,12 @@
}
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
@@ -2039,16 +1989,13 @@
return font;
}
}
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;
}
}
@@ -2113,24 +2060,18 @@
/* 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);
}
@@ -2184,13 +2125,11 @@
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);
default: return null;
@@ -2359,14 +2298,11 @@
public synchronized void deRegisterBadFont(Font2D font2D) {
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());
}
}
/*
@@ -2383,26 +2319,20 @@
/* 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;
}
}
/* eliminate references to this font, so it won't be located
@@ -2498,15 +2428,11 @@
* 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.
*/
@@ -2636,14 +2562,12 @@
/* Modifies the behaviour of a subsequent call to preferLocaleFonts()
* 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;
}
@@ -2651,13 +2575,12 @@
public boolean usingAlternateFontforJALocales() {
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) {
@@ -2667,14 +2590,12 @@
createCompositeFonts(fontNameCache, gLocalePref, gPropPref);
_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 +2831,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 +2850,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 +2900,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 +3018,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,15 +3050,11 @@
* 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++) {
String platformFontName = fcFonts[f];
@@ -3234,12 +3149,11 @@
descriptor.getExclusionRanges(),
descriptor.getExclusionRangeLimits(),
true);
}
if (FontUtilities.debugFonts()) {
- FontUtilities.getLogger()
- .info("registered " + descriptor.getFaceName());
+ FontUtilities.logInfo("registered " + descriptor.getFaceName());
}
}
}
/**
< prev index next >