if (flags != 0 && flags != GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS) {
return printGlyphVector(g, x, y);
}
Font font = g.getFont();
Font2D font2D = FontManager.getFont2D(font);
if (font2D.handle.font2D != font2D) {
/* suspicious, may be a bad font. lets bail */
return false;
}
Hashtable<Font2DHandle,Object> fontMap;
synchronized (PathGraphics.class) {
fontMap = fontMapRef.get();
if (fontMap == null) {
fontMap = new Hashtable<Font2DHandle,Object>();
fontMapRef =
new SoftReference<Hashtable<Font2DHandle,Object>>(fontMap);
}
}
int numGlyphs = g.getNumGlyphs();
int[] glyphCodes = g.getGlyphCodes(0, numGlyphs, null);
char[] glyphToCharMap = null;
char[][] mapArray = null;
CompositeFont cf = null;
/* Build the needed maps for this font in a synchronized block */
synchronized (fontMap) {
if (font2D instanceof CompositeFont) {
cf = (CompositeFont)font2D;
int numSlots = cf.getNumSlots();
mapArray = (char[][])fontMap.get(font2D.handle);
if (mapArray == null) {
mapArray = new char[numSlots][];
fontMap.put(font2D.handle, mapArray);
}
for (int i=0; i<numGlyphs;i++) {
int slot = glyphCodes[i] >>> 24;
if (slot >= numSlots) { /* shouldn't happen */
return false;
}
if (mapArray[slot] == null) {
Font2D slotFont = cf.getSlotFont(slot);
char[] map = (char[])fontMap.get(slotFont.handle);
if (map == null) {
map = getGlyphToCharMapForFont(slotFont);
}
mapArray[slot] = map;