// first look to see if we are creating an altGlyph glyph vector
if (textElement.getTagName().equals(SVG_ALT_GLYPH_TAG)) {
SVGAltGlyphElementBridge altGlyphBridge = (SVGAltGlyphElementBridge)ctx.getBridge(textElement);
Glyph[] glyphArray = altGlyphBridge.createAltGlyphArray(ctx, textElement, fontSize);
if (glyphArray != null) {
return new SVGGVTGlyphVector(this, glyphArray, frc);
}
}
// not alt-glyph or alt-glyph could not find referenced glyphs
Vector glyphs = new Vector();
char c = ci.first();
while (c != ci.DONE) {
boolean foundMatchingGlyph = false;
for (int i = 0; i < glyphUnicodes.length; i++) {
if (glyphUnicodes[i].indexOf(c) == 0) { // found a possible match
if (glyphUnicodes[i].length() == 0) { // not a ligature
Element glyphElement = glyphElements[i];
SVGGlyphElementBridge glyphBridge = (SVGGlyphElementBridge)ctx.getBridge(glyphElement);
Glyph glyph = glyphBridge.createGlyph(ctx, glyphElement, textElement, i, fontSize, fontFace);
glyphs.add(glyph);
foundMatchingGlyph = true;
break;
} else {
// glyphCodes[i] is a ligature so try and
// match the rest of the glyphCode chars
int current = ci.getIndex();
boolean matched = true;
for (int j = 1; j < glyphUnicodes[i].length(); j++) {
c = ci.next();
if (glyphUnicodes[i].charAt(j) != c) {
matched = false;
break;
}
}
if (matched) { // found a matching ligature!
Element glyphElement = glyphElements[i];
SVGGlyphElementBridge glyphBridge = (SVGGlyphElementBridge)ctx.getBridge(glyphElement);
Glyph glyph = glyphBridge.createGlyph(ctx, glyphElement, textElement, i, fontSize, fontFace);
glyphs.add(glyph);
foundMatchingGlyph = true;
break;
} else {
// did not match ligature, keep looking for another glyph
c = ci.setIndex(current);
}
}
}
}
if (!foundMatchingGlyph) {
// add the missing glyph
SVGGlyphElementBridge glyphBridge = (SVGGlyphElementBridge)ctx.getBridge(missingGlyphElement);
Glyph glyph = glyphBridge.createGlyph(ctx, missingGlyphElement, textElement, -1, fontSize, fontFace);
glyphs.add(glyph);
}
c = ci.next();
}
// turn the vector of glyphs into an array;
int numGlyphs = glyphs.size();
Glyph[] glyphArray = new Glyph[numGlyphs];
for (int i =0; i < numGlyphs; i++) {
glyphArray[i] = (Glyph)glyphs.get(i);
}
// return a new SVGGVTGlyphVector
return new SVGGVTGlyphVector(this, glyphArray, frc);
}