src/share/classes/sun/awt/FontConfiguration.java

Print this page
rev 1297 : [mq]: fontmanager.patch

*** 28,38 **** import java.awt.Font; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; - import java.io.FileOutputStream; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; import java.nio.charset.Charset; import java.nio.charset.CharsetEncoder; --- 28,37 ----
*** 47,57 **** import java.util.Map.Entry; import java.util.Properties; import java.util.Set; import java.util.Vector; import sun.font.CompositeFontDescriptor; ! import sun.java2d.SunGraphicsEnvironment; /** * Provides the definitions of the five logical fonts: Serif, SansSerif, * Monospaced, Dialog, and DialogInput. The necessary information * is obtained from fontconfig files. --- 46,58 ---- import java.util.Map.Entry; import java.util.Properties; import java.util.Set; import java.util.Vector; import sun.font.CompositeFontDescriptor; ! import sun.font.SunFontManager; ! import sun.font.FontManagerFactory; ! import sun.font.FontUtilities; /** * Provides the definitions of the five logical fonts: Serif, SansSerif, * Monospaced, Dialog, and DialogInput. The necessary information * is obtained from fontconfig files.
*** 66,76 **** protected static Hashtable localeMap = null; private static FontConfiguration fontConfig; private static Logger logger; protected static boolean isProperties = true; ! protected SunGraphicsEnvironment environment; protected boolean preferLocaleFonts; protected boolean preferPropFonts; private File fontConfigFile; private boolean foundOsSpecificFile; --- 67,77 ---- protected static Hashtable localeMap = null; private static FontConfiguration fontConfig; private static Logger logger; protected static boolean isProperties = true; ! protected SunFontManager fontManager; protected boolean preferLocaleFonts; protected boolean preferPropFonts; private File fontConfigFile; private boolean foundOsSpecificFile;
*** 78,92 **** private String javaLib; /* A default FontConfiguration must be created before an alternate * one to ensure proper static initialisation takes place. */ ! public FontConfiguration(SunGraphicsEnvironment environment) { ! if (SunGraphicsEnvironment.debugFonts && logger == null) { logger = Logger.getLogger("sun.awt.FontConfiguration"); } ! this.environment = environment; setOsNameAndVersion(); /* static initialization */ setEncoding(); /* static initialization */ /* Separating out the file location from the rest of the * initialisation, so the caller has the option of doing * something else if a suitable file isn't found. --- 79,93 ---- private String javaLib; /* A default FontConfiguration must be created before an alternate * one to ensure proper static initialisation takes place. */ ! public FontConfiguration(SunFontManager fm) { ! if (FontUtilities.debugFonts() && logger == null) { logger = Logger.getLogger("sun.awt.FontConfiguration"); } ! fontManager = fm; setOsNameAndVersion(); /* static initialization */ setEncoding(); /* static initialization */ /* Separating out the file location from the rest of the * initialisation, so the caller has the option of doing * something else if a suitable file isn't found.
*** 104,117 **** inited = true; } return true; } ! public FontConfiguration(SunGraphicsEnvironment environment, boolean preferLocaleFonts, boolean preferPropFonts) { ! this.environment = environment; this.preferLocaleFonts = preferLocaleFonts; this.preferPropFonts = preferPropFonts; /* fontConfig should be initialised by default constructor, and * its data tables can be shared, since readFontConfigFile doesn't * update any other state. Also avoid a doPrivileged block. --- 105,118 ---- inited = true; } return true; } ! public FontConfiguration(SunFontManager fm, boolean preferLocaleFonts, boolean preferPropFonts) { ! fontManager = fm; this.preferLocaleFonts = preferLocaleFonts; this.preferPropFonts = preferPropFonts; /* fontConfig should be initialised by default constructor, and * its data tables can be shared, since readFontConfigFile doesn't * update any other state. Also avoid a doPrivileged block.
*** 196,216 **** loadProperties(in); } else { loadBinary(in); } in.close(); ! if (SunGraphicsEnvironment.debugFonts) { logger.config("Read logical font configuration from " + f); } } catch (IOException e) { ! if (SunGraphicsEnvironment.debugFonts) { logger.config("Failed to read logical font configuration from " + f); } } } String version = getVersion(); ! if (!"1".equals(version) && SunGraphicsEnvironment.debugFonts) { logger.config("Unsupported fontconfig version: " + version); } } protected void getInstalledFallbackFonts(String javaLib) { --- 197,217 ---- loadProperties(in); } else { loadBinary(in); } in.close(); ! if (FontUtilities.debugFonts()) { logger.config("Read logical font configuration from " + f); } } catch (IOException e) { ! if (FontUtilities.debugFonts()) { logger.config("Failed to read logical font configuration from " + f); } } } String version = getVersion(); ! if (!"1".equals(version) && FontUtilities.debugFonts()) { logger.config("Unsupported fontconfig version: " + version); } } protected void getInstalledFallbackFonts(String javaLib) {
*** 217,228 **** String fallbackDirName = javaLib + File.separator + "fonts" + File.separator + "fallback"; File fallbackDir = new File(fallbackDirName); if (fallbackDir.exists() && fallbackDir.isDirectory()) { ! String[] ttfs = fallbackDir.list(SunGraphicsEnvironment.ttFilter); ! String[] t1s = fallbackDir.list(SunGraphicsEnvironment.t1Filter); int numTTFs = (ttfs == null) ? 0 : ttfs.length; int numT1s = (t1s == null) ? 0 : t1s.length; int len = numTTFs + numT1s; if (numTTFs + numT1s == 0) { return; --- 218,229 ---- String fallbackDirName = javaLib + File.separator + "fonts" + File.separator + "fallback"; File fallbackDir = new File(fallbackDirName); if (fallbackDir.exists() && fallbackDir.isDirectory()) { ! String[] ttfs = fallbackDir.list(fontManager.getTrueTypeFilter()); ! String[] t1s = fallbackDir.list(fontManager.getType1Filter()); int numTTFs = (ttfs == null) ? 0 : ttfs.length; int numT1s = (t1s == null) ? 0 : t1s.length; int len = numTTFs + numT1s; if (numTTFs + numT1s == 0) { return;
*** 234,244 **** } for (int i=0; i<numT1s; i++) { installedFallbackFontFiles[i+numTTFs] = fallbackDir + File.separator + t1s[i]; } ! environment.registerFontsInDir(fallbackDirName); } } private File findImpl(String fname) { File f = new File(fname + ".properties"); --- 235,245 ---- } for (int i=0; i<numT1s; i++) { installedFallbackFontFiles[i+numTTFs] = fallbackDir + File.separator + t1s[i]; } ! fontManager.registerFontsInDir(fallbackDirName); } } private File findImpl(String fname) { File f = new File(fname + ".properties");
*** 463,473 **** //core for (index = 0; index < coreScripts.length; index++) { nameIDs[index] = getComponentFontID(coreScripts[index], fontIndex, styleIndex); if (preferLocaleFonts && localeMap != null && ! sun.font.FontManager.usingAlternateFontforJALocales()) { nameIDs[index] = remapLocaleMap(fontIndex, styleIndex, coreScripts[index], nameIDs[index]); } if (preferPropFonts) { nameIDs[index] = remapProportional(fontIndex, nameIDs[index]); --- 464,474 ---- //core for (index = 0; index < coreScripts.length; index++) { nameIDs[index] = getComponentFontID(coreScripts[index], fontIndex, styleIndex); if (preferLocaleFonts && localeMap != null && ! fontManager.usingAlternateFontforJALocales()) { nameIDs[index] = remapLocaleMap(fontIndex, styleIndex, coreScripts[index], nameIDs[index]); } if (preferPropFonts) { nameIDs[index] = remapProportional(fontIndex, nameIDs[index]);
*** 478,488 **** //fallback for (int i = 0; i < fallbackScripts.length; i++) { short id = getComponentFontID(fallbackScripts[i], fontIndex, styleIndex); if (preferLocaleFonts && localeMap != null && ! sun.font.FontManager.usingAlternateFontforJALocales()) { id = remapLocaleMap(fontIndex, styleIndex, fallbackScripts[i], id); } if (preferPropFonts) { id = remapProportional(fontIndex, id); } --- 479,489 ---- //fallback for (int i = 0; i < fallbackScripts.length; i++) { short id = getComponentFontID(fallbackScripts[i], fontIndex, styleIndex); if (preferLocaleFonts && localeMap != null && ! fontManager.usingAlternateFontforJALocales()) { id = remapLocaleMap(fontIndex, styleIndex, fallbackScripts[i], id); } if (preferPropFonts) { id = remapProportional(fontIndex, id); }
*** 971,982 **** * or the given fallback font as component fonts, they are added here. */ public CompositeFontDescriptor[] get2DCompositeFontInfo() { CompositeFontDescriptor[] result = new CompositeFontDescriptor[NUM_FONTS * NUM_STYLES]; ! String defaultFontFile = environment.getDefaultFontFile(); ! String defaultFontFaceName = environment.getDefaultFontFaceName(); for (int fontIndex = 0; fontIndex < NUM_FONTS; fontIndex++) { String fontName = publicFontNames[fontIndex]; // determine exclusion ranges for font --- 972,983 ---- * or the given fallback font as component fonts, they are added here. */ public CompositeFontDescriptor[] get2DCompositeFontInfo() { CompositeFontDescriptor[] result = new CompositeFontDescriptor[NUM_FONTS * NUM_STYLES]; ! String defaultFontFile = fontManager.getDefaultFontFile(); ! String defaultFontFaceName = fontManager.getDefaultFontFaceName(); for (int fontIndex = 0; fontIndex < NUM_FONTS; fontIndex++) { String fontName = publicFontNames[fontIndex]; // determine exclusion ranges for font
*** 1119,1129 **** * to search for it. If it doesn't then unless its a fallback font, * return that expensive code should be invoked to search for the font. */ HashMap<String, Boolean> existsMap; public boolean needToSearchForFile(String fileName) { ! if (!environment.isLinux) { return false; } else if (existsMap == null) { existsMap = new HashMap<String, Boolean>(); } Boolean exists = existsMap.get(fileName); --- 1120,1130 ---- * to search for it. If it doesn't then unless its a fallback font, * return that expensive code should be invoked to search for the font. */ HashMap<String, Boolean> existsMap; public boolean needToSearchForFile(String fileName) { ! if (!FontUtilities.isLinux) { return false; } else if (existsMap == null) { existsMap = new HashMap<String, Boolean>(); } Boolean exists = existsMap.get(fileName);
*** 1137,1147 **** if (!coreFontFileNames.contains(fileName)) { exists = Boolean.TRUE; } else { exists = Boolean.valueOf((new File(fileName)).exists()); existsMap.put(fileName, exists); ! if (SunGraphicsEnvironment.debugFonts && exists == Boolean.FALSE) { logger.warning("Couldn't locate font file " + fileName); } } } --- 1138,1148 ---- if (!coreFontFileNames.contains(fileName)) { exists = Boolean.TRUE; } else { exists = Boolean.valueOf((new File(fileName)).exists()); existsMap.put(fileName, exists); ! if (FontUtilities.debugFonts() && exists == Boolean.FALSE) { logger.warning("Couldn't locate font file " + fileName); } } }
*** 2065,2075 **** up = Integer.parseInt(upper, 16); if (lo > up) { throw new Exception(); } } catch (Exception e) { ! if (SunGraphicsEnvironment.debugFonts && logger != null) { logger.config("Failed parsing " + key + " property of font configuration."); } return EMPTY_INT_ARRAY; --- 2066,2077 ---- up = Integer.parseInt(upper, 16); if (lo > up) { throw new Exception(); } } catch (Exception e) { ! if (FontUtilities.debugFonts() && ! logger != null) { logger.config("Failed parsing " + key + " property of font configuration."); } return EMPTY_INT_ARRAY;