mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8191522: Remove Bigelow&Holmes Lucida fonts from JDK sources
Reviewed-by: serb, erikj
This commit is contained in:
parent
5ff01c4163
commit
9a9dad8b63
26 changed files with 108 additions and 367 deletions
|
@ -188,12 +188,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
private boolean loaded1dot0Fonts = false;
|
||||
boolean loadedAllFonts = false;
|
||||
boolean loadedAllFontFiles = false;
|
||||
HashMap<String,String> jreFontMap;
|
||||
HashSet<String> jreLucidaFontFiles;
|
||||
String[] jreOtherFontFiles;
|
||||
boolean noOtherJREFontFiles = false; // initial assumption.
|
||||
|
||||
public static final String lucidaFontName = "Lucida Sans Regular";
|
||||
public static String jreLibDirName;
|
||||
public static String jreFontDirName;
|
||||
private static HashSet<String> missingFontFiles = null;
|
||||
|
@ -265,72 +262,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
return _usingPerAppContextComposites;
|
||||
}
|
||||
|
||||
private void initJREFontMap() {
|
||||
|
||||
/* Key is familyname+style value as an int.
|
||||
* Value is filename containing the font.
|
||||
* If no mapping exists, it means there is no font file for the style
|
||||
* If the mapping exists but the file doesn't exist in the deferred
|
||||
* list then it means its not installed.
|
||||
* This looks like a lot of code and strings but if it saves even
|
||||
* a single file being opened at JRE start-up there's a big payoff.
|
||||
* Lucida Sans is probably the only important case as the others
|
||||
* are rarely used. Consider removing the other mappings if there's
|
||||
* no evidence they are useful in practice.
|
||||
*/
|
||||
jreFontMap = new HashMap<String,String>();
|
||||
jreLucidaFontFiles = new HashSet<String>();
|
||||
if (isOpenJDK()) {
|
||||
return;
|
||||
}
|
||||
/* Lucida Sans Family */
|
||||
jreFontMap.put("lucida sans0", "LucidaSansRegular.ttf");
|
||||
jreFontMap.put("lucida sans1", "LucidaSansDemiBold.ttf");
|
||||
/* Lucida Sans full names (map Bold and DemiBold to same file) */
|
||||
jreFontMap.put("lucida sans regular0", "LucidaSansRegular.ttf");
|
||||
jreFontMap.put("lucida sans regular1", "LucidaSansDemiBold.ttf");
|
||||
jreFontMap.put("lucida sans bold1", "LucidaSansDemiBold.ttf");
|
||||
jreFontMap.put("lucida sans demibold1", "LucidaSansDemiBold.ttf");
|
||||
|
||||
/* Lucida Sans Typewriter Family */
|
||||
jreFontMap.put("lucida sans typewriter0",
|
||||
"LucidaTypewriterRegular.ttf");
|
||||
jreFontMap.put("lucida sans typewriter1", "LucidaTypewriterBold.ttf");
|
||||
/* Typewriter full names (map Bold and DemiBold to same file) */
|
||||
jreFontMap.put("lucida sans typewriter regular0",
|
||||
"LucidaTypewriter.ttf");
|
||||
jreFontMap.put("lucida sans typewriter regular1",
|
||||
"LucidaTypewriterBold.ttf");
|
||||
jreFontMap.put("lucida sans typewriter bold1",
|
||||
"LucidaTypewriterBold.ttf");
|
||||
jreFontMap.put("lucida sans typewriter demibold1",
|
||||
"LucidaTypewriterBold.ttf");
|
||||
|
||||
/* Lucida Bright Family */
|
||||
jreFontMap.put("lucida bright0", "LucidaBrightRegular.ttf");
|
||||
jreFontMap.put("lucida bright1", "LucidaBrightDemiBold.ttf");
|
||||
jreFontMap.put("lucida bright2", "LucidaBrightItalic.ttf");
|
||||
jreFontMap.put("lucida bright3", "LucidaBrightDemiItalic.ttf");
|
||||
/* Lucida Bright full names (map Bold and DemiBold to same file) */
|
||||
jreFontMap.put("lucida bright regular0", "LucidaBrightRegular.ttf");
|
||||
jreFontMap.put("lucida bright regular1", "LucidaBrightDemiBold.ttf");
|
||||
jreFontMap.put("lucida bright regular2", "LucidaBrightItalic.ttf");
|
||||
jreFontMap.put("lucida bright regular3", "LucidaBrightDemiItalic.ttf");
|
||||
jreFontMap.put("lucida bright bold1", "LucidaBrightDemiBold.ttf");
|
||||
jreFontMap.put("lucida bright bold3", "LucidaBrightDemiItalic.ttf");
|
||||
jreFontMap.put("lucida bright demibold1", "LucidaBrightDemiBold.ttf");
|
||||
jreFontMap.put("lucida bright demibold3","LucidaBrightDemiItalic.ttf");
|
||||
jreFontMap.put("lucida bright italic2", "LucidaBrightItalic.ttf");
|
||||
jreFontMap.put("lucida bright italic3", "LucidaBrightDemiItalic.ttf");
|
||||
jreFontMap.put("lucida bright bold italic3",
|
||||
"LucidaBrightDemiItalic.ttf");
|
||||
jreFontMap.put("lucida bright demibold italic3",
|
||||
"LucidaBrightDemiItalic.ttf");
|
||||
for (String ffile : jreFontMap.values()) {
|
||||
jreLucidaFontFiles.add(ffile);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
java.security.AccessController.doPrivileged(
|
||||
|
@ -354,8 +285,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
jreLibDirName =
|
||||
System.getProperty("java.home","") + File.separator + "lib";
|
||||
jreFontDirName = jreLibDirName + File.separator + "fonts";
|
||||
File lucidaFile =
|
||||
new File(jreFontDirName + File.separator + FontUtilities.LUCIDA_FILE_NAME);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -381,7 +310,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
@SuppressWarnings("unchecked")
|
||||
protected SunFontManager() {
|
||||
|
||||
initJREFontMap();
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
|
@ -438,11 +366,10 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
* that might be specified.
|
||||
*/
|
||||
fontConfig = createFontConfiguration();
|
||||
if (isOpenJDK()) {
|
||||
String[] fontInfo = getDefaultPlatformFont();
|
||||
defaultFontName = fontInfo[0];
|
||||
defaultFontFileName = fontInfo[1];
|
||||
}
|
||||
|
||||
String[] fontInfo = getDefaultPlatformFont();
|
||||
defaultFontName = fontInfo[0];
|
||||
defaultFontFileName = fontInfo[1];
|
||||
|
||||
String extraFontPath = fontConfig.getExtraFontPath();
|
||||
|
||||
|
@ -919,47 +846,20 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
return deferredFontFiles.containsKey(fileName);
|
||||
}
|
||||
|
||||
/* We keep a map of the files which contain the Lucida fonts so we
|
||||
* don't need to search for them.
|
||||
* But since we know what fonts these files contain, we can also avoid
|
||||
* opening them to look for a font name we don't recognise - see
|
||||
* findDeferredFont().
|
||||
* For typical cases where the font isn't a JRE one the overhead is
|
||||
* this method call, HashMap.get() and null reference test, then
|
||||
* a boolean test of noOtherJREFontFiles.
|
||||
*/
|
||||
public
|
||||
/*private*/ PhysicalFont findJREDeferredFont(String name, int style) {
|
||||
|
||||
PhysicalFont physicalFont;
|
||||
String nameAndStyle = name.toLowerCase(Locale.ENGLISH) + style;
|
||||
String fileName = jreFontMap.get(nameAndStyle);
|
||||
if (fileName != null) {
|
||||
fileName = jreFontDirName + File.separator + fileName;
|
||||
if (deferredFontFiles.get(fileName) != null) {
|
||||
physicalFont = initialiseDeferredFont(fileName);
|
||||
if (physicalFont != null &&
|
||||
(physicalFont.getFontName(null).equalsIgnoreCase(name) ||
|
||||
physicalFont.getFamilyName(null).equalsIgnoreCase(name))
|
||||
&& physicalFont.style == style) {
|
||||
return physicalFont;
|
||||
}
|
||||
}
|
||||
}
|
||||
PhysicalFont findJREDeferredFont(String name, int style) {
|
||||
|
||||
/* Iterate over the deferred font files looking for any in the
|
||||
* jre directory that we didn't recognise, open each of these.
|
||||
* In almost all installations this will quickly fall through
|
||||
* because only the Lucidas will be present and jreOtherFontFiles
|
||||
* will be empty.
|
||||
* because jreOtherFontFiles will be empty.
|
||||
* noOtherJREFontFiles is used so we can skip this block as soon
|
||||
* as its determined that its not needed - almost always after the
|
||||
* as its determined that it's not needed - almost always after the
|
||||
* very first time through.
|
||||
*/
|
||||
if (noOtherJREFontFiles) {
|
||||
return null;
|
||||
}
|
||||
synchronized (jreLucidaFontFiles) {
|
||||
synchronized (jreFontDirName) {
|
||||
if (jreOtherFontFiles == null) {
|
||||
HashSet<String> otherFontFiles = new HashSet<String>();
|
||||
for (String deferredFile : deferredFontFiles.keySet()) {
|
||||
|
@ -969,9 +869,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
/* skip names which aren't absolute, aren't in the JRE
|
||||
* directory, or are known Lucida fonts.
|
||||
*/
|
||||
if (dir == null ||
|
||||
!dir.equals(jreFontDirName) ||
|
||||
jreLucidaFontFiles.contains(fname)) {
|
||||
if (dir == null || !dir.equals(jreFontDirName)) {
|
||||
continue;
|
||||
}
|
||||
otherFontFiles.add(deferredFile);
|
||||
|
@ -983,12 +881,12 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
}
|
||||
|
||||
for (int i=0; i<jreOtherFontFiles.length;i++) {
|
||||
fileName = jreOtherFontFiles[i];
|
||||
String fileName = jreOtherFontFiles[i];
|
||||
if (fileName == null) {
|
||||
continue;
|
||||
}
|
||||
jreOtherFontFiles[i] = null;
|
||||
physicalFont = initialiseDeferredFont(fileName);
|
||||
PhysicalFont physicalFont = initialiseDeferredFont(fileName);
|
||||
if (physicalFont != null &&
|
||||
(physicalFont.getFontName(null).equalsIgnoreCase(name) ||
|
||||
physicalFont.getFamilyName(null).equalsIgnoreCase(name))
|
||||
|
@ -1001,17 +899,8 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
return null;
|
||||
}
|
||||
|
||||
/* This skips JRE installed fonts. */
|
||||
private PhysicalFont findOtherDeferredFont(String name, int style) {
|
||||
for (String fileName : deferredFontFiles.keySet()) {
|
||||
File file = new File(fileName);
|
||||
String dir = file.getParent();
|
||||
String fname = file.getName();
|
||||
if (dir != null &&
|
||||
dir.equals(jreFontDirName) &&
|
||||
jreLucidaFontFiles.contains(fname)) {
|
||||
continue;
|
||||
}
|
||||
PhysicalFont physicalFont = initialiseDeferredFont(fileName);
|
||||
if (physicalFont != null &&
|
||||
(physicalFont.getFontName(null).equalsIgnoreCase(name) ||
|
||||
|
@ -1024,7 +913,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
}
|
||||
|
||||
private PhysicalFont findDeferredFont(String name, int style) {
|
||||
|
||||
PhysicalFont physicalFont = findJREDeferredFont(name, style);
|
||||
if (physicalFont != null) {
|
||||
return physicalFont;
|
||||
|
@ -1196,11 +1084,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
* misconfiguration and this is probably a reasonable substitution.
|
||||
*/
|
||||
defaultPhysicalFont = (PhysicalFont)
|
||||
findFont2D("Lucida Sans Regular", Font.PLAIN, NO_FALLBACK);
|
||||
if (defaultPhysicalFont == null) {
|
||||
defaultPhysicalFont = (PhysicalFont)
|
||||
findFont2D("Arial", Font.PLAIN, NO_FALLBACK);
|
||||
}
|
||||
findFont2D(getDefaultFontFaceName(), Font.PLAIN, NO_FALLBACK);
|
||||
if (defaultPhysicalFont == null) {
|
||||
/* Because of the findFont2D call above, if we reach here, we
|
||||
* know all fonts have already been loaded, just accept any
|
||||
|
@ -2197,9 +2081,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
fontNameCache.put(mapName, font);
|
||||
return font;
|
||||
}
|
||||
|
||||
/* Don't want Windows to return a Lucida Sans font from
|
||||
* C:\Windows\Fonts
|
||||
/* Don't want Windows to return a font from C:\Windows\Fonts
|
||||
* if someone has installed a font with the same name
|
||||
* in the JRE.
|
||||
*/
|
||||
if (deferredFontFiles.size() > 0) {
|
||||
font = findJREDeferredFont(lowerCaseName, style);
|
||||
|
@ -3285,10 +3169,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
return fontPath;
|
||||
}
|
||||
|
||||
public static boolean isOpenJDK() {
|
||||
return FontUtilities.isOpenJDK;
|
||||
}
|
||||
|
||||
protected void loadFonts() {
|
||||
if (discoveredAllFonts) {
|
||||
return;
|
||||
|
@ -3379,24 +3259,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
* or relative as needed by registerFontFile.
|
||||
*/
|
||||
public synchronized String getDefaultFontFile() {
|
||||
if (defaultFontFileName == null) {
|
||||
initDefaultFonts();
|
||||
}
|
||||
return defaultFontFileName;
|
||||
}
|
||||
|
||||
private void initDefaultFonts() {
|
||||
if (!isOpenJDK()) {
|
||||
defaultFontName = lucidaFontName;
|
||||
if (useAbsoluteFontFileNames()) {
|
||||
defaultFontFileName =
|
||||
jreFontDirName + File.separator + FontUtilities.LUCIDA_FILE_NAME;
|
||||
} else {
|
||||
defaultFontFileName = FontUtilities.LUCIDA_FILE_NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether registerFontFile expects absolute or relative
|
||||
* font file names.
|
||||
|
@ -3420,9 +3285,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||
* for this platform.
|
||||
*/
|
||||
public synchronized String getDefaultFontFaceName() {
|
||||
if (defaultFontName == null) {
|
||||
initDefaultFonts();
|
||||
}
|
||||
return defaultFontName;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue