if (fontSizeFloat != null) {
fontSize = fontSizeFloat.floatValue();
}
Vector gvtFonts = new Vector();
for (int i = 0; i < resolvedFontFamilies.size(); i++) {
GVTFont font = ((GVTFontFamily)resolvedFontFamilies.get(i)).deriveFont(fontSize, runaci);
gvtFonts.add(font);
}
// now for each char or group of chars in the string,
// find a font that can display it
int runaciLength = end-start;
boolean[] fontAssigned = new boolean[runaciLength];
for (int i = 0; i < runaciLength; i++) {
fontAssigned[i] = false;
}
for (int i = 0; i < gvtFonts.size(); i++) {
// assign this font to all characters it can display if it has
// not already been assigned
GVTFont font = (GVTFont)gvtFonts.get(i);
int currentRunIndex = runaci.getBeginIndex();
while (currentRunIndex < runaci.getEndIndex()) {
int displayUpToIndex = font.canDisplayUpTo(runaci, currentRunIndex, end);
if (displayUpToIndex == -1) {
// for each char, if not already assigned a font, assign this font to it
for (int j = currentRunIndex; j < end; j++) {
if (!fontAssigned[j - start]) {
as.addAttribute(GVTAttributedCharacterIterator.TextAttribute.GVT_FONT, font, j, j+1);
fontAssigned[j - start] = true;
}
}
currentRunIndex = runaci.getEndIndex();
} else if (displayUpToIndex > currentRunIndex) {
// could display some but not all
// for each char it can display, if not already assigned a font, assign this font to it
for (int j = currentRunIndex; j < displayUpToIndex; j++) {
if (!fontAssigned[j - start]) {
as.addAttribute(GVTAttributedCharacterIterator.TextAttribute.GVT_FONT, font, j, j+1);
fontAssigned[j - start] = true;
}
}
// set currentRunIndex to be one after the char couldn't display
currentRunIndex = displayUpToIndex+1;
} else {
// couldn't display the current char
currentRunIndex++;
}
}
}
// assign the first font to any chars haven't alreay been assigned
for (int i = 0; i < runaciLength; i++) {
if (!fontAssigned[i]) {
GVTFontFamily fontFamily = FontFamilyResolver.getFamilyThatCanDisplay(runaci.setIndex(start+i));
if (fontFamily != null) {
GVTFont font = fontFamily.deriveFont(fontSize, runaci);
as.addAttribute(GVTAttributedCharacterIterator.TextAttribute.GVT_FONT,
font, start+i, start+i+1);
} else {
// no available fonts can display it, just use the first font in the list
as.addAttribute(GVTAttributedCharacterIterator.TextAttribute.GVT_FONT,