src/share/classes/sun/font/CompositeFont.java

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

*** 58,68 **** boolean isStdComposite = true; public CompositeFont(String name, String[] compFileNames, String[] compNames, int metricsSlotCnt, int[] exclRanges, int[] maxIndexes, ! boolean defer) { handle = new Font2DHandle(this); fullName = name; componentFileNames = compFileNames; componentNames = compNames; --- 58,68 ---- boolean isStdComposite = true; public CompositeFont(String name, String[] compFileNames, String[] compNames, int metricsSlotCnt, int[] exclRanges, int[] maxIndexes, ! boolean defer, SunFontManager fm) { handle = new Font2DHandle(this); fullName = name; componentFileNames = compFileNames; componentNames = compNames;
*** 83,107 **** * See if this is a windows locale which has a system EUDC font. * If so add it as the final fallback component of the composite. * The caller could be responsible for this, but for now it seems * better that it is handled internally to the CompositeFont class. */ ! if (FontManager.eudcFont != null) { numSlots++; if (componentNames != null) { componentNames = new String[numSlots]; System.arraycopy(compNames, 0, componentNames, 0, numSlots-1); componentNames[numSlots-1] = ! FontManager.eudcFont.getFontName(null); } if (componentFileNames != null) { componentFileNames = new String[numSlots]; System.arraycopy(compFileNames, 0, componentFileNames, 0, numSlots-1); } components = new PhysicalFont[numSlots]; ! components[numSlots-1] = FontManager.eudcFont; deferredInitialisation = new boolean[numSlots]; if (defer) { for (int i=0; i<numSlots-1; i++) { deferredInitialisation[i] = true; } --- 83,107 ---- * See if this is a windows locale which has a system EUDC font. * If so add it as the final fallback component of the composite. * The caller could be responsible for this, but for now it seems * better that it is handled internally to the CompositeFont class. */ ! if (fm.getEUDCFont() != null) { numSlots++; if (componentNames != null) { componentNames = new String[numSlots]; System.arraycopy(compNames, 0, componentNames, 0, numSlots-1); componentNames[numSlots-1] = ! fm.getEUDCFont().getFontName(null); } if (componentFileNames != null) { componentFileNames = new String[numSlots]; System.arraycopy(compFileNames, 0, componentFileNames, 0, numSlots-1); } components = new PhysicalFont[numSlots]; ! components[numSlots-1] = fm.getEUDCFont(); deferredInitialisation = new boolean[numSlots]; if (defer) { for (int i=0; i<numSlots-1; i++) { deferredInitialisation[i] = true; }
*** 163,173 **** * We need to ensure that the arrays have consistent information. * But it may be possible to dispense with the synchronisation if * it is harmless that we do not know a slot is already initialised * and just need to discover that and mark it so. */ ! synchronized (FontManager.class) { components = new PhysicalFont[numSlots]; components[0] = physFont; System.arraycopy(compFont.components, 0, components, 1, compFont.numSlots); --- 163,173 ---- * We need to ensure that the arrays have consistent information. * But it may be possible to dispense with the synchronisation if * it is harmless that we do not know a slot is already initialised * and just need to discover that and mark it so. */ ! synchronized (FontManagerFactory.getInstance()) { components = new PhysicalFont[numSlots]; components[0] = physFont; System.arraycopy(compFont.components, 0, components, 1, compFont.numSlots);
*** 233,243 **** /* Synchronize on FontManager so that is the global lock * to update its static set of deferred fonts. * This global lock is rarely likely to be an issue as there * are only going to be a few calls into this code. */ ! synchronized (FontManager.class) { if (componentNames == null) { componentNames = new String[numSlots]; } if (components[slot] == null) { /* Warning: it is possible that the returned component is --- 233,244 ---- /* Synchronize on FontManager so that is the global lock * to update its static set of deferred fonts. * This global lock is rarely likely to be an issue as there * are only going to be a few calls into this code. */ ! SunFontManager fm = SunFontManager.getInstance(); ! synchronized (fm) { if (componentNames == null) { componentNames = new String[numSlots]; } if (components[slot] == null) { /* Warning: it is possible that the returned component is
*** 249,272 **** * make no further use of this file, but code debuggers/ * maintainers need to be conscious of this possibility. */ if (componentFileNames != null && componentFileNames[slot] != null) { ! components[slot] = FontManager.initialiseDeferredFont ! (componentFileNames[slot]); } if (components[slot] == null) { ! components[slot] = FontManager.getDefaultPhysicalFont(); } String name = components[slot].getFontName(null); if (componentNames[slot] == null) { componentNames[slot] = name; } else if (!componentNames[slot].equalsIgnoreCase(name)) { components[slot] = ! (PhysicalFont) ! FontManager.findFont2D(componentNames[slot], style, FontManager.PHYSICAL_FALLBACK); } } deferredInitialisation[slot] = false; --- 250,272 ---- * make no further use of this file, but code debuggers/ * maintainers need to be conscious of this possibility. */ if (componentFileNames != null && componentFileNames[slot] != null) { ! components[slot] = ! fm.initialiseDeferredFont(componentFileNames[slot]); } if (components[slot] == null) { ! components[slot] = fm.getDefaultPhysicalFont(); } String name = components[slot].getFontName(null); if (componentNames[slot] == null) { componentNames[slot] = name; } else if (!componentNames[slot].equalsIgnoreCase(name)) { components[slot] = ! (PhysicalFont) fm.findFont2D(componentNames[slot], style, FontManager.PHYSICAL_FALLBACK); } } deferredInitialisation[slot] = false;
*** 331,355 **** * (as that is the only frequent call site of this method. */ if (deferredInitialisation[slot]) { doDeferredInitialisation(slot); } try { PhysicalFont font = components[slot]; if (font == null) { try { ! font = (PhysicalFont)FontManager. findFont2D(componentNames[slot], style, FontManager.PHYSICAL_FALLBACK); components[slot] = font; } catch (ClassCastException cce) { ! font = FontManager.getDefaultPhysicalFont(); } } return font; } catch (Exception e) { ! return FontManager.getDefaultPhysicalFont(); } } FontStrike createStrike(FontStrikeDesc desc) { return new CompositeStrike(this, desc); --- 331,356 ---- * (as that is the only frequent call site of this method. */ if (deferredInitialisation[slot]) { doDeferredInitialisation(slot); } + SunFontManager fm = SunFontManager.getInstance(); try { PhysicalFont font = components[slot]; if (font == null) { try { ! font = (PhysicalFont) fm. findFont2D(componentNames[slot], style, FontManager.PHYSICAL_FALLBACK); components[slot] = font; } catch (ClassCastException cce) { ! font = fm.getDefaultPhysicalFont(); } } return font; } catch (Exception e) { ! return fm.getDefaultPhysicalFont(); } } FontStrike createStrike(FontStrikeDesc desc) { return new CompositeStrike(this, desc);