mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8248802: Add log helper methods to FontUtilities.java
Reviewed-by: clanger, jdv
This commit is contained in:
parent
13bcda40dc
commit
7a0914c44c
14 changed files with 139 additions and 198 deletions
|
@ -320,7 +320,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
break;
|
||||
} else {
|
||||
if (FontUtilities.debugFonts()) {
|
||||
FontUtilities.getLogger().warning("read bad font: " + name);
|
||||
FontUtilities.logWarning("read bad font: " + name);
|
||||
}
|
||||
badFonts.add(name);
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
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];
|
||||
|
||||
|
@ -403,10 +403,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -562,10 +561,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -625,8 +623,8 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
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);
|
||||
|
@ -699,21 +697,18 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
*/
|
||||
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 +
|
||||
",Font " + fontName + " new rank="+rank +
|
||||
" from " + oldFont.platName +
|
||||
" with " + newFont.platName);
|
||||
FontUtilities.logInfo("Replace in Family " + familyName +
|
||||
",Font " + fontName + " new rank="+rank +
|
||||
" from " + oldFont.platName +
|
||||
" with " + newFont.platName);
|
||||
}
|
||||
replaceFont(oldFont, newFont);
|
||||
physicalFonts.put(fontName, newFont);
|
||||
|
@ -903,8 +898,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
return null;
|
||||
}
|
||||
if (FontUtilities.isLogging()) {
|
||||
FontUtilities.getLogger()
|
||||
.info("Opening deferred font file " + fileNameKey);
|
||||
FontUtilities.logInfo("Opening deferred font file " + fileNameKey);
|
||||
}
|
||||
|
||||
PhysicalFont physicalFont = null;
|
||||
|
@ -991,14 +985,12 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
|
||||
}
|
||||
if (FontUtilities.isLogging()) {
|
||||
FontUtilities.getLogger()
|
||||
.info("Registered file " + fileName + " as font " +
|
||||
physicalFont + " rank=" + fontRank);
|
||||
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 &&
|
||||
|
@ -1042,8 +1034,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
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));
|
||||
}
|
||||
}
|
||||
|
@ -1304,8 +1295,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
}
|
||||
fontToFamilyNameMap.remove(name);
|
||||
if (FontUtilities.isLogging()) {
|
||||
FontUtilities.getLogger()
|
||||
.info("No file for font:" + name);
|
||||
FontUtilities.logInfo("No file for font:" + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1355,8 +1345,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
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) {
|
||||
|
@ -1400,8 +1389,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
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);
|
||||
|
@ -1411,9 +1399,8 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
fontToFileMap.put(fontName, file);
|
||||
unmappedFonts.remove(fontName);
|
||||
if (FontUtilities.isLogging()) {
|
||||
FontUtilities.getLogger()
|
||||
.info("Resolved absent registry entry for " +
|
||||
fontName + " located in " + fullPath);
|
||||
FontUtilities.logInfo("Resolved absent registry entry for " +
|
||||
fontName + " located in " + fullPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1538,8 +1525,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
|
||||
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;
|
||||
|
@ -1566,8 +1552,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
|
||||
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;
|
||||
|
@ -1834,9 +1819,8 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
String fileName = fontToFileMap.get(fontNameLC);
|
||||
if (fileName == null) {
|
||||
if (FontUtilities.isLogging()) {
|
||||
FontUtilities.getLogger()
|
||||
.info("Platform lookup : No file for font " +
|
||||
fontList[f] + " in family " +familyName);
|
||||
FontUtilities.logInfo("Platform lookup : No file for font " +
|
||||
fontList[f] + " in family " +familyName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1905,9 +1889,8 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
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
|
||||
|
@ -2021,9 +2004,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
|
||||
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;
|
||||
|
@ -2042,10 +2025,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
font = findFontFromPlatform(lowerCaseName, style);
|
||||
if (font != null) {
|
||||
if (FontUtilities.isLogging()) {
|
||||
FontUtilities.getLogger()
|
||||
.info("Found font via platform API for request:\"" +
|
||||
name + "\":, style="+style+
|
||||
" found font: " + font);
|
||||
FontUtilities.logInfo("Found font via platform API for request:\"" +
|
||||
name + "\":, style="+style+
|
||||
" found font: " + font);
|
||||
}
|
||||
fontNameCache.put(mapName, font);
|
||||
return font;
|
||||
|
@ -2116,8 +2098,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
*/
|
||||
if (!loadedAllFonts) {
|
||||
if (FontUtilities.isLogging()) {
|
||||
FontUtilities.getLogger()
|
||||
.info("Load fonts looking for:" + name);
|
||||
FontUtilities.logInfo("Load fonts looking for:" + name);
|
||||
}
|
||||
loadFonts();
|
||||
loadedAllFonts = true;
|
||||
|
@ -2126,8 +2107,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
|
||||
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;
|
||||
|
@ -2185,9 +2165,8 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
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) {
|
||||
|
@ -2362,8 +2341,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
return;
|
||||
} else {
|
||||
if (FontUtilities.isLogging()) {
|
||||
FontUtilities.getLogger()
|
||||
.severe("Deregister bad font: " + font2D);
|
||||
FontUtilities.logSevere("Deregister bad font: " + font2D);
|
||||
}
|
||||
replaceFont((PhysicalFont)font2D, getDefaultPhysicalFont());
|
||||
}
|
||||
|
@ -2386,8 +2364,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
*/
|
||||
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++) {
|
||||
|
@ -2398,8 +2375,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
}
|
||||
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;
|
||||
}
|
||||
|
@ -2500,10 +2476,8 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
* 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
|
||||
|
@ -2639,9 +2613,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
*/
|
||||
public synchronized void useAlternateFontforJALocales() {
|
||||
if (FontUtilities.isLogging()) {
|
||||
FontUtilities.getLogger()
|
||||
.info("Entered useAlternateFontforJALocales().");
|
||||
FontUtilities.logInfo("Entered useAlternateFontforJALocales().");
|
||||
}
|
||||
|
||||
if (!FontUtilities.isWindows) {
|
||||
return;
|
||||
}
|
||||
|
@ -2654,8 +2628,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
|
||||
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;
|
||||
|
@ -2670,9 +2645,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
|
||||
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.
|
||||
*/
|
||||
|
@ -2912,8 +2887,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
|
||||
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.
|
||||
}
|
||||
|
@ -2932,7 +2906,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
message += ", " + natNames[nn];
|
||||
}
|
||||
}
|
||||
FontUtilities.getLogger().info(message);
|
||||
FontUtilities.logInfo(message);
|
||||
}
|
||||
fontNames[fontCount] = fullName;
|
||||
nativeNames[fontCount++] = getNativeNames(fullName, null);
|
||||
|
@ -2982,8 +2956,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
synchronized (this) {
|
||||
if (FontUtilities.debugFonts()) {
|
||||
Thread.dumpStack();
|
||||
FontUtilities.getLogger()
|
||||
.info("SunGraphicsEnvironment.loadFonts() called");
|
||||
FontUtilities.logInfo("SunGraphicsEnvironment.loadFonts() called");
|
||||
}
|
||||
initialiseDeferredFonts();
|
||||
|
||||
|
@ -3101,7 +3074,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
synchronized (this) {
|
||||
if (FontUtilities.debugFonts()) {
|
||||
Thread.dumpStack();
|
||||
FontUtilities.getLogger().info("loadAllFontFiles() called");
|
||||
FontUtilities.logInfo("loadAllFontFiles() called");
|
||||
}
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
|
@ -3133,10 +3106,8 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
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();
|
||||
|
@ -3236,8 +3207,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
true);
|
||||
}
|
||||
if (FontUtilities.debugFonts()) {
|
||||
FontUtilities.getLogger()
|
||||
.info("registered " + descriptor.getFaceName());
|
||||
FontUtilities.logInfo("registered " + descriptor.getFaceName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue