165 try { 166 File f = new File(fileName); 167 return Boolean.valueOf(f.exists()); 168 } 169 catch (Exception e) { 170 return Boolean.FALSE; 171 } 172 } 173 }); 174 return exists.booleanValue(); 175 } 176 177 private void findFontConfigFile() { 178 179 foundOsSpecificFile = true; // default assumption. 180 String javaHome = System.getProperty("java.home"); 181 if (javaHome == null) { 182 throw new Error("java.home property not set"); 183 } 184 javaLib = javaHome + File.separator + "lib"; 185 String userConfigFile = System.getProperty("sun.awt.fontconfig"); 186 if (userConfigFile != null) { 187 fontConfigFile = new File(userConfigFile); 188 } else { 189 fontConfigFile = findFontConfigFile(javaLib); 190 } 191 } 192 193 private void readFontConfigFile(File f) { 194 /* This is invoked here as readFontConfigFile is only invoked 195 * once per VM, and always in a privileged context, thus the 196 * directory containing installed fall back fonts is accessed 197 * from this context 198 */ 199 getInstalledFallbackFonts(javaLib); 200 201 if (f != null) { 202 try { 203 FileInputStream in = new FileInputStream(f.getPath()); 204 if (isProperties) { 205 loadProperties(in); 206 } else { 207 loadBinary(in); 208 } 258 if (FontUtilities.debugFonts()) { 259 logger.info("Found file : " + f); 260 } 261 isProperties = true; 262 return f; 263 } 264 f = new File(fname + ".bfc"); 265 if (FontUtilities.debugFonts()) { 266 logger.info("Looking for binary fontconfig file : " + f); 267 } 268 if (f.canRead()) { 269 if (FontUtilities.debugFonts()) { 270 logger.info("Found file : " + f); 271 } 272 isProperties = false; 273 return f; 274 } 275 return null; 276 } 277 278 private File findFontConfigFile(String javaLib) { 279 String baseName = javaLib + File.separator + "fontconfig"; 280 File configFile; 281 String osMajorVersion = null; 282 if (osVersion != null && osName != null) { 283 configFile = findImpl(baseName + "." + osName + "." + osVersion); 284 if (configFile != null) { 285 return configFile; 286 } 287 int decimalPointIndex = osVersion.indexOf('.'); 288 if (decimalPointIndex != -1) { 289 osMajorVersion = osVersion.substring(0, osVersion.indexOf('.')); 290 configFile = findImpl(baseName + "." + osName + "." + osMajorVersion); 291 if (configFile != null) { 292 return configFile; 293 } 294 } 295 } 296 if (osName != null) { 297 configFile = findImpl(baseName + "." + osName); 298 if (configFile != null) { 299 return configFile; | 165 try { 166 File f = new File(fileName); 167 return Boolean.valueOf(f.exists()); 168 } 169 catch (Exception e) { 170 return Boolean.FALSE; 171 } 172 } 173 }); 174 return exists.booleanValue(); 175 } 176 177 private void findFontConfigFile() { 178 179 foundOsSpecificFile = true; // default assumption. 180 String javaHome = System.getProperty("java.home"); 181 if (javaHome == null) { 182 throw new Error("java.home property not set"); 183 } 184 javaLib = javaHome + File.separator + "lib"; 185 String javaConfFonts = javaHome + 186 File.separator + "conf" + 187 File.separator + "fonts"; 188 String userConfigFile = System.getProperty("sun.awt.fontconfig"); 189 if (userConfigFile != null) { 190 fontConfigFile = new File(userConfigFile); 191 } else { 192 fontConfigFile = findFontConfigFile(javaConfFonts); 193 } 194 if (fontConfigFile == null) { 195 fontConfigFile = findFontConfigFile(javaLib); 196 } 197 } 198 199 private void readFontConfigFile(File f) { 200 /* This is invoked here as readFontConfigFile is only invoked 201 * once per VM, and always in a privileged context, thus the 202 * directory containing installed fall back fonts is accessed 203 * from this context 204 */ 205 getInstalledFallbackFonts(javaLib); 206 207 if (f != null) { 208 try { 209 FileInputStream in = new FileInputStream(f.getPath()); 210 if (isProperties) { 211 loadProperties(in); 212 } else { 213 loadBinary(in); 214 } 264 if (FontUtilities.debugFonts()) { 265 logger.info("Found file : " + f); 266 } 267 isProperties = true; 268 return f; 269 } 270 f = new File(fname + ".bfc"); 271 if (FontUtilities.debugFonts()) { 272 logger.info("Looking for binary fontconfig file : " + f); 273 } 274 if (f.canRead()) { 275 if (FontUtilities.debugFonts()) { 276 logger.info("Found file : " + f); 277 } 278 isProperties = false; 279 return f; 280 } 281 return null; 282 } 283 284 private File findFontConfigFile(String dir) { 285 if (!(new File(dir)).exists()) { 286 return null; 287 } 288 String baseName = dir + File.separator + "fontconfig"; 289 File configFile; 290 String osMajorVersion = null; 291 if (osVersion != null && osName != null) { 292 configFile = findImpl(baseName + "." + osName + "." + osVersion); 293 if (configFile != null) { 294 return configFile; 295 } 296 int decimalPointIndex = osVersion.indexOf('.'); 297 if (decimalPointIndex != -1) { 298 osMajorVersion = osVersion.substring(0, osVersion.indexOf('.')); 299 configFile = findImpl(baseName + "." + osName + "." + osMajorVersion); 300 if (configFile != null) { 301 return configFile; 302 } 303 } 304 } 305 if (osName != null) { 306 configFile = findImpl(baseName + "." + osName); 307 if (configFile != null) { 308 return configFile; |