Author: jeremias
Date: Tue Dec 2 07:21:36 2008
New Revision: 722496
URL: http://svn.apache.org/viewvc?rev=722496&view=rev
Log:
Bugfix: there was no notification if no registered internal font can be found
for a GVT font. Now, FontInfo will issue a substitution warning.
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java?rev=722496&r1=722495&r2=722496&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java Tue
Dec 2 07:21:36 2008
@@ -43,6 +43,7 @@
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 @@
&& (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 @@
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 @@
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 @@
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();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]