8248802: Add log helper methods to FontUtilities.java

Reviewed-by: clanger, jdv
This commit is contained in:
Matthias Baesken 2020-07-14 17:02:48 +02:00
parent 13bcda40dc
commit 7a0914c44c
14 changed files with 139 additions and 198 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -96,8 +96,8 @@ public final class CFontManager extends SunFontManager {
// already existing fonts in this list
if (logicalFont || !genericFonts.containsKey(fontName)) {
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger().info("Add to Family "+familyName +
", Font " + fontName + " rank="+rank);
FontUtilities.logInfo("Add to Family " + familyName +
", Font " + fontName + " rank=" + rank);
}
FontFamily family = FontFamily.getFamily(familyName);
if (family == null) {

View File

@ -83,8 +83,7 @@ public abstract class FontConfiguration {
*/
public FontConfiguration(SunFontManager fm) {
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger()
.info("Creating standard Font Configuration");
FontUtilities.logInfo("Creating standard Font Configuration");
}
if (FontUtilities.debugFonts() && logger == null) {
logger = PlatformLogger.getLogger("sun.awt.FontConfiguration");
@ -116,8 +115,7 @@ public abstract class FontConfiguration {
boolean preferPropFonts) {
fontManager = fm;
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger()
.info("Creating alternate Font Configuration");
FontUtilities.logInfo("Creating alternate Font Configuration");
}
this.preferLocaleFonts = preferLocaleFonts;
this.preferPropFonts = preferPropFonts;

View File

@ -400,10 +400,8 @@ abstract class CMap {
} else {
subtableLength = buffer.getInt(offset+4) & INTMASK;
}
if (offset+subtableLength > buffer.capacity()) {
if (FontUtilities.isLogging()) {
FontUtilities.getLogger().warning("Cmap subtable overflows buffer.");
}
if (FontUtilities.isLogging() && offset + subtableLength > buffer.capacity()) {
FontUtilities.logWarning("Cmap subtable overflows buffer.");
}
switch (subtableFormat) {
case 0: return new CMapFormat0(buffer, offset);
@ -422,11 +420,8 @@ abstract class CMap {
int subtableFormat = buffer.getChar(offset);
if (subtableFormat == 14) {
long subtableLength = buffer.getInt(offset + 2) & INTMASK;
if (offset + subtableLength > buffer.capacity()) {
if (FontUtilities.isLogging()) {
FontUtilities.getLogger()
.warning("Cmap UVS subtable overflows buffer.");
}
if (FontUtilities.isLogging() && offset + subtableLength > buffer.capacity()) {
FontUtilities.logWarning("Cmap UVS subtable overflows buffer.");
}
try {
this.uvs = new UVS(buffer, offset);

View File

@ -223,8 +223,7 @@ public class FileFontStrike extends PhysicalStrike {
useNatives = true;
}
if (FontUtilities.isLogging() && FontUtilities.isWindows) {
FontUtilities.getLogger().info
("Strike for " + fileFont + " at size = " + intPtSize +
FontUtilities.logInfo("Strike for " + fileFont + " at size = " + intPtSize +
" use natives = " + useNatives +
" useJavaRasteriser = " + fileFont.useJavaRasterizer +
" AAHint = " + desc.aaHint +
@ -319,8 +318,7 @@ public class FileFontStrike extends PhysicalStrike {
return ptr;
} else {
if (FontUtilities.isLogging()) {
FontUtilities.getLogger().warning(
"Failed to render glyph using GDI: code=" + glyphCode
FontUtilities.logWarning("Failed to render glyph using GDI: code=" + glyphCode
+ ", fontFamily=" + family + ", style=" + style
+ ", size=" + size);
}
@ -356,14 +354,13 @@ public class FileFontStrike extends PhysicalStrike {
if (useNatives) {
glyphPtr = getGlyphImageFromNative(glyphCode);
if (glyphPtr == 0L && FontUtilities.isLogging()) {
FontUtilities.getLogger().info
("Strike for " + fileFont +
FontUtilities.logInfo("Strike for " + fileFont +
" at size = " + intPtSize +
" couldn't get native glyph for code = " + glyphCode);
}
} if (glyphPtr == 0L) {
glyphPtr = fileFont.getGlyphImage(pScalerContext,
glyphCode);
}
if (glyphPtr == 0L) {
glyphPtr = fileFont.getGlyphImage(pScalerContext, glyphCode);
}
return setCachedGlyphPtr(glyphCode, glyphPtr);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -181,7 +181,7 @@ public class FontFamily {
Math.abs(Font2D.FWIDTH_NORMAL - familyWidth))
{
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger().info(
FontUtilities.logInfo(
"Found more preferred width. New width = " + newWidth +
" Old width = " + familyWidth + " in font " + font +
" nulling out fonts plain: " + plain + " bold: " + bold +
@ -191,7 +191,7 @@ public class FontFamily {
plain = bold = italic = bolditalic = null;
return true;
} else if (FontUtilities.debugFonts()) {
FontUtilities.getLogger().info(
FontUtilities.logInfo(
"Family rejecting font " + font +
" of less preferred width " + newWidth);
}
@ -208,7 +208,7 @@ public class FontFamily {
}
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger().info(
FontUtilities.logInfo(
"New weight for style " + style + ". Curr.font=" + currFont +
" New font="+font+" Curr.weight="+ + currFont.getWeight()+
" New weight="+font.getWeight());
@ -242,15 +242,14 @@ public class FontFamily {
msg = "Request to add " + font +
" with style " + style + " to family " + this;
}
FontUtilities.getLogger().info(msg);
FontUtilities.logInfo(msg);
}
/* Allow a lower-rank font only if its a file font
* from the exact same source as any previous font.
*/
if ((font.getRank() > familyRank) && !isFromSameSource(font)) {
if (FontUtilities.isLogging()) {
FontUtilities.getLogger()
.warning("Rejecting adding " + font +
FontUtilities.logWarning("Rejecting adding " + font +
" of lower rank " + font.getRank() +
" to family " + this +
" of rank " + familyRank);

View File

@ -26,10 +26,6 @@
package sun.font;
import java.awt.Font;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.lang.ref.SoftReference;
import java.util.concurrent.ConcurrentHashMap;
import java.security.AccessController;
@ -112,10 +108,6 @@ public final class FontUtilities {
} else if (debugLevel.equals("severe")) {
logger.setLevel(PlatformLogger.Level.SEVERE);
}
}
if (debugFonts) {
logger = PlatformLogger.getLogger("sun.java2d");
logging = logger.isEnabled();
}
@ -324,6 +316,17 @@ public final class FontUtilities {
return debugFonts;
}
public static void logWarning(String s) {
getLogger().warning(s);
}
public static void logInfo(String s) {
getLogger().info(s);
}
public static void logSevere(String s) {
getLogger().severe(s);
}
// The following methods are used by Swing.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -478,8 +478,7 @@ public final class GlyphLayout {
if (_gvdata._count < 0) {
gv = new StandardGlyphVector(font, text, offset, count, frc);
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger().warning("OpenType layout failed on font: " +
font);
FontUtilities.logWarning("OpenType layout failed on font: " + font);
}
} else {
gv = _gvdata.createGlyphVector(font, frc, result);

View File

@ -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,18 +697,15 @@ 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 +
FontUtilities.logInfo("Replace in Family " + familyName +
",Font " + fontName + " new rank="+rank +
" from " + oldFont.platName +
" with " + newFont.platName);
@ -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 " +
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,8 +1399,7 @@ 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 " +
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,8 +1819,7 @@ 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 " +
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,8 +2025,7 @@ 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:\"" +
FontUtilities.logInfo("Found font via platform API for request:\"" +
name + "\":, style="+style+
" found font: " + 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());
}
}
}

View File

@ -244,7 +244,7 @@ public class TrueTypeFont extends FileFont {
throws FontFormatException {
if (disposerRecord.channel == null) {
if (FontUtilities.isLogging()) {
FontUtilities.getLogger().info("open TTF: " + platName);
FontUtilities.logInfo("open TTF: " + platName);
}
try {
RandomAccessFile raf = AccessController.doPrivileged(
@ -312,7 +312,7 @@ public class TrueTypeFont extends FileFont {
String msg = "Read offset is " + offset +
" file size is " + fileSize+
" file is " + platName;
FontUtilities.getLogger().severe(msg);
FontUtilities.logSevere(msg);
}
return -1;
} else {
@ -331,7 +331,7 @@ public class TrueTypeFont extends FileFont {
" and now is " + currSize;
}
if (FontUtilities.isLogging()) {
FontUtilities.getLogger().severe(msg);
FontUtilities.logSevere(msg);
}
// We could still flip() the buffer here because
// it's possible that we did read some data in
@ -346,9 +346,8 @@ public class TrueTypeFont extends FileFont {
if (bread > length/2 || bread > 16384) {
buffer.flip();
if (FontUtilities.isLogging()) {
msg = "Returning " + bread +
" bytes instead of " + length;
FontUtilities.getLogger().severe(msg);
msg = "Returning " + bread + " bytes instead of " + length;
FontUtilities.logSevere(msg);
}
} else {
bread = -1;
@ -364,8 +363,7 @@ public class TrueTypeFont extends FileFont {
}
} catch (FontFormatException e) {
if (FontUtilities.isLogging()) {
FontUtilities.getLogger().severe(
"While reading " + platName, e);
FontUtilities.getLogger().severe("While reading " + platName, e);
}
bread = -1; // signal EOF
deregisterFontAndClearStrikeCache();
@ -385,8 +383,7 @@ public class TrueTypeFont extends FileFont {
* file are handled as a FontFormatException.
*/
if (FontUtilities.isLogging()) {
FontUtilities.getLogger().severe(
"While reading " + platName, e);
FontUtilities.getLogger().severe("While reading " + platName, e);
}
if (bread == 0) {
bread = -1; // signal EOF
@ -523,7 +520,7 @@ public class TrueTypeFont extends FileFont {
initNames();
} catch (Exception e) {
if (FontUtilities.isLogging()) {
FontUtilities.getLogger().severe(e.toString());
FontUtilities.logSevere(e.toString());
}
if (e instanceof FontFormatException) {
throw (FontFormatException)e;
@ -1073,7 +1070,7 @@ public class TrueTypeFont extends FileFont {
return new String(bytes, 0, len, charset);
} catch (UnsupportedEncodingException e) {
if (FontUtilities.isLogging()) {
FontUtilities.getLogger().warning(e + " EncodingID=" + encoding);
FontUtilities.logWarning(e + " EncodingID=" + encoding);
}
return new String(bytes, 0, len);
} catch (Throwable t) {

View File

@ -74,8 +74,7 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
return glyphCode;
} else {
if (FontUtilities.isLogging()) {
FontUtilities.getLogger().warning
(font + " out of range glyph id=" +
FontUtilities.logWarning(font + " out of range glyph id=" +
Integer.toHexString((int)glyphCode) +
" for char " + Integer.toHexString(charCode));
}
@ -99,8 +98,7 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
return glyphCode;
} else {
if (FontUtilities.isLogging()) {
FontUtilities.getLogger().warning
(font + " out of range glyph id=" +
FontUtilities.logWarning(font + " out of range glyph id=" +
Integer.toHexString((int)glyphCode) +
" for char " + Integer.toHexString(charCode) +
" for vs " + Integer.toHexString(variationSelector));
@ -115,9 +113,10 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
private void handleBadCMAP() {
if (FontUtilities.isLogging()) {
FontUtilities.getLogger().severe("Null Cmap for " + font +
FontUtilities.logSevere("Null Cmap for " + font +
"substituting for this font");
}
SunFontManager.getInstance().deRegisterBadFont(font);
/* The next line is not really a solution, but might
* reduce the exceptions until references to this font2D

View File

@ -224,15 +224,13 @@ public final class X11FontManager extends FcFontManager {
if (fontPath == null &&
(fileName == null || !fileName.startsWith("/"))) {
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger()
.warning("** Registering all font paths because " +
FontUtilities.logWarning("** Registering all font paths because " +
"can't find file for " + platName);
}
fontPath = getPlatformFontPath(noType1Font);
registerFontDirs(fontPath);
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger()
.warning("** Finished registering all font paths");
FontUtilities.logWarning("** Finished registering all font paths");
}
fileName = fontNameMap.get(fontID);
}
@ -289,7 +287,7 @@ public final class X11FontManager extends FcFontManager {
* ...
*/
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger().info("ParseFontDir " + path);
FontUtilities.logInfo("ParseFontDir " + path);
}
File fontsDotDir = new File(path + File.separator + "fonts.dir");
FileReader fr = null;
@ -368,10 +366,9 @@ public final class X11FontManager extends FcFontManager {
String sVal = fontNameMap.get(fontID);
if (FontUtilities.debugFonts()) {
PlatformLogger logger = FontUtilities.getLogger();
logger.info("file=" + fileName +
FontUtilities.logInfo("file=" + fileName +
" xlfd=" + fontPart);
logger.info("fontID=" + fontID +
FontUtilities.logInfo("fontID=" + fontID +
" sVal=" + sVal);
}
String fullPath = null;
@ -394,15 +391,13 @@ public final class X11FontManager extends FcFontManager {
}
Vector<String> xVal = xlfdMap.get(fullPath);
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger()
.info("fullPath=" + fullPath +
FontUtilities.logInfo("fullPath=" + fullPath +
" xVal=" + xVal);
}
if ((xVal == null || !xVal.contains(fontPart)) &&
(sVal == null) || !sVal.startsWith("/")) {
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger()
.info("Map fontID:"+fontID +
FontUtilities.logInfo("Map fontID:"+fontID +
"to file:" + fullPath);
}
fontNameMap.put(fontID, fullPath);
@ -481,8 +476,7 @@ public final class X11FontManager extends FcFontManager {
if (hyphenCnt != 14) {
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger()
.severe("Font Configuration Font ID is malformed:" + name);
FontUtilities.logSevere("Font Configuration Font ID is malformed:" + name);
}
return name; // what else can we do?
}
@ -511,8 +505,7 @@ public final class X11FontManager extends FcFontManager {
if (hyphenCnt != 14) {
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger()
.severe("Font Configuration Font ID is malformed:" + name);
FontUtilities.logSevere("Font Configuration Font ID is malformed:" + name);
}
return name; // what else can we do?
}
@ -675,7 +668,7 @@ public final class X11FontManager extends FcFontManager {
if (FontUtilities.debugFonts() && fontConfigDirs != null) {
String[] names = fontConfigDirs.toArray(new String[0]);
for (int i=0;i<names.length;i++) {
FontUtilities.getLogger().info("awtfontpath : " + names[i]);
FontUtilities.logInfo("awtfontpath : " + names[i]);
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -540,8 +540,7 @@ public class FcFontConfiguration extends FontConfiguration {
}
if (FontUtilities.debugFonts()) {
PlatformLogger logger = FontUtilities.getLogger();
logger.info("successfully parsed the fontconfig file at " + fcFile.toString());
FontUtilities.logInfo("successfully parsed the fontconfig file at " + fcFile.toString());
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -195,9 +195,7 @@ public class FontConfigManager {
FcCompFont fci = fontArr[i];
if (fci.firstFont == null) {
if (FontUtilities.isLogging()) {
PlatformLogger logger = FontUtilities.getLogger();
logger.info("Fontconfig returned no font for " +
fontArr[i].fcName);
FontUtilities.logInfo("Fontconfig returned no font for " + fontArr[i].fcName);
}
fontConfigFailed = true;
} else if (anyFont == null) {
@ -207,8 +205,7 @@ public class FontConfigManager {
if (anyFont == null) {
if (FontUtilities.isLogging()) {
PlatformLogger logger = FontUtilities.getLogger();
logger.info("Fontconfig returned no fonts at all.");
FontUtilities.logInfo("Fontconfig returned no fonts at all.");
}
fontConfigFailed = true;
return;
@ -223,22 +220,19 @@ public class FontConfigManager {
fontConfigFonts = fontArr;
if (FontUtilities.isLogging()) {
PlatformLogger logger = FontUtilities.getLogger();
long t1 = System.nanoTime();
logger.info("Time spent accessing fontconfig="
FontUtilities.logInfo("Time spent accessing fontconfig="
+ ((t1 - t0) / 1000000) + "ms.");
for (int i = 0; i< fontConfigFonts.length; i++) {
FcCompFont fci = fontConfigFonts[i];
logger.info("FC font " + fci.fcName+" maps to family " +
FontUtilities.logInfo("FC font " + fci.fcName+" maps to family " +
fci.firstFont.familyName +
" in file " + fci.firstFont.fontFile);
if (fci.allFonts != null) {
for (int f=0;f<fci.allFonts.length;f++) {
FontConfigFont fcf = fci.allFonts[f];
logger.info("Family=" + fcf.familyName +
FontUtilities.logInfo("Family=" + fcf.familyName +
" Style="+ fcf.styleStr +
" Fullname="+fcf.fullName +
" File="+fcf.fontFile);
@ -360,8 +354,7 @@ public class FontConfigManager {
}
if (FontUtilities.isLogging()) {
FontUtilities.getLogger()
.info("FC name=" + name + " style=" + style +
FontUtilities.logInfo("FC name=" + name + " style=" + style +
" uses " + fcInfo.firstFont.familyName +
" in file: " + fcInfo.firstFont.fontFile);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -116,8 +116,7 @@ class NativeStrike extends PhysicalStrike {
pScalerContext = createNullScalerContext();
numGlyphs = 0;
if (FontUtilities.isLogging()) {
FontUtilities.getLogger()
.severe("Could not create native strike " +
FontUtilities.logSevere("Could not create native strike " +
new String(nameBytes));
}
return;