You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ja...@apache.org on 2014/09/04 19:23:58 UTC

svn commit: r1622514 - /pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java

Author: jahewson
Date: Thu Sep  4 17:23:58 2014
New Revision: 1622514

URL: http://svn.apache.org/r1622514
Log:
PDFBOX-2307: Map undefined glyph names to GID 0

Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java?rev=1622514&r1=1622513&r2=1622514&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java Thu Sep  4 17:23:58 2014
@@ -419,8 +419,8 @@ public class TrueTypeFont implements Typ
     {
         readPostScriptNames();
 
-        Integer gid = postScriptNames.get(name);
-        if (gid == null || gid < 0 || gid >= getMaximumProfile().getNumGlyphs())
+        int gid = nameToGID(name);
+        if (gid < 0 || gid >= getMaximumProfile().getNumGlyphs())
         {
             gid = 0;
         }
@@ -449,20 +449,15 @@ public class TrueTypeFont implements Typ
     {
         readPostScriptNames();
 
-        Integer gid = postScriptNames.get(name);
+        Integer gid = nameToGID(name);
 
-        if (gid != null)
+        int width = getAdvanceWidth(gid);
+        int unitsPerEM = getUnitsPerEm();
+        if (unitsPerEM != 1000)
         {
-            int width = getAdvanceWidth(gid);
-            int unitsPerEM = getUnitsPerEm();
-            if (unitsPerEM != 1000)
-            {
-                width *= 1000f / unitsPerEM;
-            }
-            return width;
+            width *= 1000f / unitsPerEM;
         }
-
-        throw new IOException(name + " is not in the 'post' table");
+        return width;
     }
 
     @Override