src/share/classes/sun/font/CompositeFont.java
Print this page
rev 1297 : [mq]: fontmanager.patch
@@ -58,11 +58,11 @@
boolean isStdComposite = true;
public CompositeFont(String name, String[] compFileNames,
String[] compNames, int metricsSlotCnt,
int[] exclRanges, int[] maxIndexes,
- boolean defer) {
+ boolean defer, SunFontManager fm) {
handle = new Font2DHandle(this);
fullName = name;
componentFileNames = compFileNames;
componentNames = compNames;
@@ -83,25 +83,25 @@
* 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) {
+ if (fm.getEUDCFont() != null) {
numSlots++;
if (componentNames != null) {
componentNames = new String[numSlots];
System.arraycopy(compNames, 0, componentNames, 0, numSlots-1);
componentNames[numSlots-1] =
- FontManager.eudcFont.getFontName(null);
+ 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] = FontManager.eudcFont;
+ components[numSlots-1] = fm.getEUDCFont();
deferredInitialisation = new boolean[numSlots];
if (defer) {
for (int i=0; i<numSlots-1; i++) {
deferredInitialisation[i] = true;
}
@@ -163,11 +163,11 @@
* 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) {
+ synchronized (FontManagerFactory.getInstance()) {
components = new PhysicalFont[numSlots];
components[0] = physFont;
System.arraycopy(compFont.components, 0,
components, 1, compFont.numSlots);
@@ -233,11 +233,12 @@
/* 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) {
+ 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,24 +250,23 @@
* 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]);
+ components[slot] =
+ fm.initialiseDeferredFont(componentFileNames[slot]);
}
if (components[slot] == null) {
- components[slot] = FontManager.getDefaultPhysicalFont();
+ 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)
- FontManager.findFont2D(componentNames[slot],
+ (PhysicalFont) fm.findFont2D(componentNames[slot],
style,
FontManager.PHYSICAL_FALLBACK);
}
}
deferredInitialisation[slot] = false;
@@ -331,25 +331,26 @@
* (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)FontManager.
+ font = (PhysicalFont) fm.
findFont2D(componentNames[slot], style,
FontManager.PHYSICAL_FALLBACK);
components[slot] = font;
} catch (ClassCastException cce) {
- font = FontManager.getDefaultPhysicalFont();
+ font = fm.getDefaultPhysicalFont();
}
}
return font;
} catch (Exception e) {
- return FontManager.getDefaultPhysicalFont();
+ return fm.getDefaultPhysicalFont();
}
}
FontStrike createStrike(FontStrikeDesc desc) {
return new CompositeStrike(this, desc);