aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/ps/PSFontUtils.java
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2006-01-10 13:19:54 +0000
committerJeremias Maerki <jeremias@apache.org>2006-01-10 13:19:54 +0000
commitc36ecae6e622d125f0ff253cfdacf855ffdfc33c (patch)
tree9a91b76b160fd78b6b1e79e294192577f54b9ceb /src/java/org/apache/fop/render/ps/PSFontUtils.java
parentfe4f89a5b0997983c73d365d4a36324320a96330 (diff)
downloadxmlgraphics-fop-c36ecae6e622d125f0ff253cfdacf855ffdfc33c.tar.gz
xmlgraphics-fop-c36ecae6e622d125f0ff253cfdacf855ffdfc33c.zip
Fixed ugly NPE (with no message) when a malconfigured font was processed by the PS Renderer (even when that font is not used). When the font is used we don't get an NPE anymore but a Runtime exception. Not ideal, but a little better, especially because of the error message. I hope that at some point someone finds time to clean up the whole exception handling in FOP.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@367593 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/ps/PSFontUtils.java')
-rw-r--r--src/java/org/apache/fop/render/ps/PSFontUtils.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/java/org/apache/fop/render/ps/PSFontUtils.java b/src/java/org/apache/fop/render/ps/PSFontUtils.java
index f209eaab0..3478a0751 100644
--- a/src/java/org/apache/fop/render/ps/PSFontUtils.java
+++ b/src/java/org/apache/fop/render/ps/PSFontUtils.java
@@ -32,6 +32,7 @@ import javax.xml.transform.stream.StreamSource;
import org.apache.commons.io.EndianUtils;
import org.apache.commons.io.IOUtils;
import org.apache.fop.fonts.CustomFont;
+import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontType;
import org.apache.fop.fonts.Glyphs;
@@ -68,6 +69,12 @@ public class PSFontUtils {
if (tf instanceof LazyFont) {
tf = ((LazyFont)tf).getRealFont();
}
+ if (tf == null) {
+ //This is to avoid an NPE if a malconfigured font is in the configuration but not
+ //used in the document. If it were used, we wouldn't get this far.
+ String fallbackKey = fontInfo.getInternalFontKey(Font.DEFAULT_FONT);
+ tf = (Typeface)fonts.get(fallbackKey);
+ }
PSResource fontRes = new PSResource("font", tf.getFontName());
fontResources.put(key, fontRes);
boolean embeddedFont = false;
@@ -104,7 +111,9 @@ public class PSFontUtils {
while (iter.hasNext()) {
String key = (String)iter.next();
Typeface fm = (Typeface)fonts.get(key);
- if (null == fm.getEncoding()) {
+ if (fm instanceof LazyFont && ((LazyFont)fm).getRealFont() == null) {
+ continue;
+ } else if (null == fm.getEncoding()) {
//ignore (ZapfDingbats and Symbol run through here
//TODO: ZapfDingbats and Symbol should get getEncoding() fixed!
} else if ("WinAnsiEncoding".equals(fm.getEncoding())) {