235 public synchronized FontConfigManager getFontConfigManager() { 236 if (fcManager == null) { 237 fcManager = new FontConfigManager(); 238 } 239 return fcManager; 240 } 241 */ 242 243 protected void registerFontsInDir(String dirName, boolean useJavaRasterizer, int fontRank, boolean defer, boolean resolveSymLinks) { 244 loadNativeDirFonts(dirName); 245 super.registerFontsInDir(dirName, useJavaRasterizer, fontRank, defer, resolveSymLinks); 246 } 247 248 private native void loadNativeDirFonts(String dirName); 249 private native void loadNativeFonts(); 250 251 void registerFont(String fontName, String fontFamilyName) { 252 final CFont font = new CFont(fontName, fontFamilyName); 253 254 registerGenericFont(font); 255 256 if ((font.getStyle() & Font.ITALIC) == 0) { 257 registerGenericFont(font.createItalicVariant(), true); 258 } 259 } 260 261 Object waitForFontsToBeLoaded = new Object(); 262 public void loadFonts() 263 { 264 synchronized(waitForFontsToBeLoaded) 265 { 266 super.loadFonts(); 267 java.security.AccessController.doPrivileged( 268 new java.security.PrivilegedAction<Object>() { 269 public Object run() { 270 loadNativeFonts(); 271 return null; 272 } 273 } 274 ); 275 276 String defaultFont = "Lucida Grande"; 277 String defaultFallback = "Lucida Sans"; 278 279 setupLogicalFonts("Dialog", defaultFont, defaultFallback); 280 setupLogicalFonts("Serif", "Times", "Lucida Bright"); 281 setupLogicalFonts("SansSerif", defaultFont, defaultFallback); 282 setupLogicalFonts("Monospaced", "Menlo", "Lucida Sans Typewriter"); 283 setupLogicalFonts("DialogInput", defaultFont, defaultFallback); 284 } 285 } 286 287 protected void setupLogicalFonts(String logicalName, String realName, String fallbackName) { 288 FontFamily realFamily = getFontFamilyWithExtraTry(logicalName, realName, fallbackName); 289 290 cloneStyledFont(realFamily, logicalName, Font.PLAIN); | 235 public synchronized FontConfigManager getFontConfigManager() { 236 if (fcManager == null) { 237 fcManager = new FontConfigManager(); 238 } 239 return fcManager; 240 } 241 */ 242 243 protected void registerFontsInDir(String dirName, boolean useJavaRasterizer, int fontRank, boolean defer, boolean resolveSymLinks) { 244 loadNativeDirFonts(dirName); 245 super.registerFontsInDir(dirName, useJavaRasterizer, fontRank, defer, resolveSymLinks); 246 } 247 248 private native void loadNativeDirFonts(String dirName); 249 private native void loadNativeFonts(); 250 251 void registerFont(String fontName, String fontFamilyName) { 252 final CFont font = new CFont(fontName, fontFamilyName); 253 254 registerGenericFont(font); 255 } 256 257 void registerItalicDerived() { 258 FontFamily[] famArr = FontFamily.getAllFontFamilies(); 259 for (int i=0; i<famArr.length; i++) { 260 FontFamily family = famArr[i]; 261 262 Font2D f2dPlain = family.getFont(Font.PLAIN); 263 if (f2dPlain != null && !(f2dPlain instanceof CFont)) continue; 264 Font2D f2dBold = family.getFont(Font.BOLD); 265 if (f2dBold != null && !(f2dBold instanceof CFont)) continue; 266 Font2D f2dItalic = family.getFont(Font.ITALIC); 267 if (f2dItalic != null && !(f2dItalic instanceof CFont)) continue; 268 Font2D f2dBoldItalic = family.getFont(Font.BOLD|Font.ITALIC); 269 if (f2dBoldItalic != null && !(f2dBoldItalic instanceof CFont)) continue; 270 271 CFont plain = (CFont)f2dPlain; 272 CFont bold = (CFont)f2dBold; 273 CFont italic = (CFont)f2dItalic; 274 CFont boldItalic = (CFont)f2dBoldItalic; 275 276 if (bold == null) bold = plain; 277 if (plain == null && bold == null) continue; 278 if (italic != null && boldItalic != null) continue; 279 if (plain != null && italic == null) { 280 registerGenericFont(plain.createItalicVariant(), true); 281 CFont f = plain.createItalicVariant(); 282 registerGenericFont(f, true); 283 } 284 if (bold != null && boldItalic == null) { 285 registerGenericFont(bold.createItalicVariant(), true); 286 CFont f = bold.createItalicVariant(); 287 registerGenericFont(f, true); 288 } 289 } 290 } 291 292 Object waitForFontsToBeLoaded = new Object(); 293 private boolean loadedAllFonts = false; 294 295 public void loadFonts() 296 { 297 synchronized(waitForFontsToBeLoaded) 298 { 299 super.loadFonts(); 300 java.security.AccessController.doPrivileged( 301 new java.security.PrivilegedAction<Object>() { 302 public Object run() { 303 if (!loadedAllFonts) { 304 loadNativeFonts(); 305 registerItalicDerived(); 306 loadedAllFonts = true; 307 } 308 return null; 309 } 310 } 311 ); 312 313 String defaultFont = "Lucida Grande"; 314 String defaultFallback = "Lucida Sans"; 315 316 setupLogicalFonts("Dialog", defaultFont, defaultFallback); 317 setupLogicalFonts("Serif", "Times", "Lucida Bright"); 318 setupLogicalFonts("SansSerif", defaultFont, defaultFallback); 319 setupLogicalFonts("Monospaced", "Menlo", "Lucida Sans Typewriter"); 320 setupLogicalFonts("DialogInput", defaultFont, defaultFallback); 321 } 322 } 323 324 protected void setupLogicalFonts(String logicalName, String realName, String fallbackName) { 325 FontFamily realFamily = getFontFamilyWithExtraTry(logicalName, realName, fallbackName); 326 327 cloneStyledFont(realFamily, logicalName, Font.PLAIN); |