pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1688307 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox: pdmodel/font/ rendering/
Date Mon, 29 Jun 2015 21:19:48 GMT
Author: jahewson
Date: Mon Jun 29 21:19:48 2015
New Revision: 1688307

URL: http://svn.apache.org/r1688307
Log:
PDFBOX-2842: Check the underlying font for missing glyphs and map the glyph name

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/Type1Glyph2D.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java?rev=1688307&r1=1688306&r2=1688307&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDSimpleFont.java Mon
Jun 29 21:19:48 2015
@@ -432,6 +432,13 @@ public abstract class PDSimpleFont exten
     public abstract GeneralPath getPath(String name) throws IOException;
 
     /**
+     * Returns true if the font contains the character with the given name.
+     *
+     * @throws IOException if the path could not be read
+     */
+    public abstract boolean hasGlyph(String name) throws IOException;
+
+    /**
      * Returns the embedded or system font used for rendering. This is never null.
      */
     public abstract FontBoxFont getFontBoxFont();

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java?rev=1688307&r1=1688306&r2=1688307&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java Mon
Jun 29 21:19:48 2015
@@ -409,6 +409,13 @@ public class PDTrueTypeFont extends PDSi
     }
 
     @Override
+    public boolean hasGlyph(String name) throws IOException
+    {
+        int gid = ttf.nameToGID(name);
+        return gid != 0;
+    }
+
+    @Override
     public FontBoxFont getFontBoxFont()
     {
         return ttf;

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java?rev=1688307&r1=1688306&r2=1688307&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java Mon
Jun 29 21:19:48 2015
@@ -157,6 +157,12 @@ public class PDType1CFont extends PDSimp
     }
 
     @Override
+    public boolean hasGlyph(String name) throws IOException
+    {
+        return genericFont.hasGlyph(name);
+    }
+
+    @Override
     public String getName()
     {
         return getBaseFont();

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java?rev=1688307&r1=1688306&r2=1688307&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java Mon
Jun 29 21:19:48 2015
@@ -466,11 +466,17 @@ public class PDType1Font extends PDSimpl
         }
         else
         {
-            return genericFont.getPath(name);
+            return genericFont.getPath(getNameInFont(name));
         }
     }
 
     @Override
+    public boolean hasGlyph(String name) throws IOException
+    {
+        return genericFont.hasGlyph(getNameInFont(name));
+    }
+
+    @Override
     public Matrix getFontMatrix()
     {
         if (fontMatrix == null)

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java?rev=1688307&r1=1688306&r2=1688307&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java Mon
Jun 29 21:19:48 2015
@@ -94,6 +94,13 @@ public class PDType3Font extends PDSimpl
     }
 
     @Override
+    public boolean hasGlyph(String name) throws IOException
+    {
+        COSStream stream = (COSStream) getCharProcs().getDictionaryObject(COSName.getPDFName(name));
+        return stream != null;
+    }
+
+    @Override
     public FontBoxFont getFontBoxFont()
     {
         // Type 3 fonts do not use FontBox fonts

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/Type1Glyph2D.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/Type1Glyph2D.java?rev=1688307&r1=1688306&r2=1688307&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/Type1Glyph2D.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/Type1Glyph2D.java Mon Jun
29 21:19:48 2015
@@ -57,7 +57,7 @@ final class Type1Glyph2D implements Glyp
         try
         {
             String name = font.getEncoding().getName(code);
-            if (name.equals(".notdef"))
+            if (!font.hasGlyph(name))
             {
                 LOG.warn("No glyph for " + code + " (" + name + ") in font " + font.getName());
             }



Mime
View raw message