From: Jeremias Maerki Date: Tue, 2 Dec 2008 15:21:36 +0000 (+0000) Subject: Bugfix: there was no notification if no registered internal font can be found for... X-Git-Tag: fop-1_0~371 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5757d4d80b19759d397e4813cf437c5f6cb66168;p=xmlgraphics-fop.git Bugfix: there was no notification if no registered internal font can be found for a GVT font. Now, FontInfo will issue a substitution warning. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@722496 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/svg/PDFTextPainter.java b/src/java/org/apache/fop/svg/PDFTextPainter.java index 8a0feb3a2..85447a4f9 100644 --- a/src/java/org/apache/fop/svg/PDFTextPainter.java +++ b/src/java/org/apache/fop/svg/PDFTextPainter.java @@ -43,6 +43,7 @@ import org.apache.batik.gvt.renderer.StrokingTextPainter; import org.apache.batik.gvt.text.GVTAttributedCharacterIterator; import org.apache.batik.gvt.text.TextPaintInfo; import org.apache.batik.gvt.text.TextSpanLayout; + import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontTriplet; @@ -284,7 +285,7 @@ public class PDFTextPainter extends StrokingTextPainter { && (taWeight.floatValue() > 1.0)) ? Font.WEIGHT_BOLD : Font.WEIGHT_NORMAL; - String fontFamily = null; + String firstFontFamily = null; //GVT_FONT can sometimes be different from the fonts in GVT_FONT_FAMILIES //or GVT_FONT_FAMILIES can even be empty and only GVT_FONT is set @@ -306,6 +307,7 @@ public class PDFTextPainter extends StrokingTextPainter { int fsize = (int)(fontSize.floatValue() * 1000); fonts.add(fontInfo.getFontInstance(triplet, fsize)); } + firstFontFamily = gvtFontFamily; } catch (Exception e) { //Most likely NoSuchMethodError here when using Batik 1.6 //Just skip this section in this case @@ -319,7 +321,7 @@ public class PDFTextPainter extends StrokingTextPainter { if (fam instanceof SVGFontFamily) { return null; //Let Batik paint this text! } - fontFamily = fam.getFamilyName(); + String fontFamily = fam.getFamilyName(); if (DEBUG) { System.out.print(fontFamily + ", "); } @@ -329,15 +331,20 @@ public class PDFTextPainter extends StrokingTextPainter { int fsize = (int)(fontSize.floatValue() * 1000); fonts.add(fontInfo.getFontInstance(triplet, fsize)); } + if (firstFontFamily == null) { + firstFontFamily = fontFamily; + } } } if (fonts.size() == 0) { - FontTriplet triplet = fontInfo.fontLookup("any", style, Font.WEIGHT_NORMAL); + 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); int fsize = (int)(fontSize.floatValue() * 1000); fonts.add(fontInfo.getFontInstance(triplet, fsize)); - if (DEBUG) { - System.out.print("fallback to 'any' font"); - } } if (DEBUG) { System.out.println();