From e4cc262c1fac77fc38286b412b6293f1f1767ec8 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Tue, 19 Feb 2008 15:43:31 +0000 Subject: Fixed NPE when no AFM is available and the PFM didn't provide a xHeight. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@629129 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/fonts/type1/Type1FontLoader.java | 36 +++++++++++++--------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java index 009a446f9..910ee82cc 100644 --- a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java +++ b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java @@ -216,11 +216,13 @@ public class Type1FontLoader extends FontLoader { //(the following are all optional in AFM, but FontBBox is always available) if (returnFont.getXHeight(1) == 0) { int xHeight = 0; - AFMCharMetrics chm = afm.getChar("x"); - if (chm != null) { - RectangularShape rect = chm.getBBox(); - if (rect != null) { - xHeight = (int)Math.round(rect.getMinX()); + if (afm != null) { + AFMCharMetrics chm = afm.getChar("x"); + if (chm != null) { + RectangularShape rect = chm.getBBox(); + if (rect != null) { + xHeight = (int)Math.round(rect.getMinX()); + } } } if (xHeight == 0) { @@ -230,11 +232,13 @@ public class Type1FontLoader extends FontLoader { } if (returnFont.getAscender() == 0) { int asc = 0; - AFMCharMetrics chm = afm.getChar("d"); - if (chm != null) { - RectangularShape rect = chm.getBBox(); - if (rect != null) { - asc = (int)Math.round(rect.getMinX()); + if (afm != null) { + AFMCharMetrics chm = afm.getChar("d"); + if (chm != null) { + RectangularShape rect = chm.getBBox(); + if (rect != null) { + asc = (int)Math.round(rect.getMinX()); + } } } if (asc == 0) { @@ -244,11 +248,13 @@ public class Type1FontLoader extends FontLoader { } if (returnFont.getDescender() == 0) { int desc = 0; - AFMCharMetrics chm = afm.getChar("p"); - if (chm != null) { - RectangularShape rect = chm.getBBox(); - if (rect != null) { - desc = (int)Math.round(rect.getMinX()); + if (afm != null) { + AFMCharMetrics chm = afm.getChar("p"); + if (chm != null) { + RectangularShape rect = chm.getBBox(); + if (rect != null) { + desc = (int)Math.round(rect.getMinX()); + } } } if (desc == 0) { -- cgit v1.2.3