]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugfix: there was no notification if no registered internal font can be found for...
authorJeremias Maerki <jeremias@apache.org>
Tue, 2 Dec 2008 15:21:36 +0000 (15:21 +0000)
committerJeremias Maerki <jeremias@apache.org>
Tue, 2 Dec 2008 15:21:36 +0000 (15:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@722496 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/svg/PDFTextPainter.java

index 8a0feb3a234a1cb6fa6bff16abff6fd4d49fa49f..85447a4f95e4ced87164a5f2f2108c9cf3f95302 100644 (file)
@@ -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();