GVTFont gvtFont = (GVTFont)aci.getAttribute(
GVTAttributedCharacterIterator.TextAttribute.GVT_FONT);
if (gvtFont != null) {
String gvtFontFamily = gvtFont.getFamilyName();
if (fontInfo.hasFont(gvtFontFamily, style, weight)) {
FontTriplet triplet = fontInfo.fontLookup(gvtFontFamily, style,
weight);
Font f = fontInfo.getFontInstance(triplet, fsize);
if (LOG.isDebugEnabled()) {
LOG.debug("Found a font that matches the GVT font: "
+ gvtFontFamily + ", " + weight + ", " + style
+ " -> " + f);
}
fonts.add(f);
}
firstFontFamily = gvtFontFamily;
}
if (gvtFonts != null) {
boolean haveInstanceOfSVGFontFamily = false;
for (GVTFontFamily fam : gvtFonts) {
if (fam instanceof SVGFontFamily) {
haveInstanceOfSVGFontFamily = true;
}
String fontFamily = fam.getFamilyName();
if (fontInfo.hasFont(fontFamily, style, weight)) {
FontTriplet triplet = fontInfo.fontLookup(fontFamily, style,
weight);
Font f = fontInfo.getFontInstance(triplet, fsize);
if (LOG.isDebugEnabled()) {
LOG.debug("Found a font that matches the GVT font family: "
+ fontFamily + ", " + weight + ", " + style
+ " -> " + f);
}
fonts.add(f);
}
if (firstFontFamily == null) {
firstFontFamily = fontFamily;
}
}
// SVG fonts are embedded fonts in the SVG document and are rarely used; however if they
// are used but the fonts also exists in the system and are known to FOP then FOP should
// use them; then the decision whether Batik should stroke the text should be made after
// no matching fonts are found
if (fonts.isEmpty() && haveInstanceOfSVGFontFamily) {
fontInfo.notifyStrokingSVGTextAsShapes(firstFontFamily);
return null; // Let Batik paint this text!
}
}
if (fonts.isEmpty()) {
if (firstFontFamily == null) {
//This will probably never happen. Just to be on the safe side.
firstFontFamily = "any";
}
//lookup with fallback possibility (incl. substitution notification)
FontTriplet triplet = fontInfo.fontLookup(firstFontFamily, style, weight);
Font f = fontInfo.getFontInstance(triplet, fsize);
if (LOG.isDebugEnabled()) {
LOG.debug("Falling back to adjustable font lookup up for: "
+ firstFontFamily + ", " + weight + ", " + style
+ " -> " + f);