pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1626296 - in /pdfbox/trunk: fontbox/src/main/java/org/apache/fontbox/ttf/ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/
Date Fri, 19 Sep 2014 18:57:22 GMT
Author: jahewson
Date: Fri Sep 19 18:57:22 2014
New Revision: 1626296

URL: http://svn.apache.org/r1626296
Log:
PDFBOX-2334: Handle non-symbolic TTF encoding

Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/PostScriptTable.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
    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/PDType0Font.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/PostScriptTable.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/PostScriptTable.java?rev=1626296&r1=1626295&r2=1626296&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/PostScriptTable.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/PostScriptTable.java Fri Sep
19 18:57:22 2014
@@ -301,4 +301,16 @@ public class PostScriptTable extends TTF
     {
         this.glyphNames = glyphNamesValue;
     }
+
+    /**
+     * @return Returns the glyph name.
+     */
+    public String getName(int gid)
+    {
+        if (gid < 0 || gid > glyphNames.length)
+        {
+            return null;
+        }
+        return glyphNames[gid];
+    }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java?rev=1626296&r1=1626295&r2=1626296&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java Fri Sep 19
18:57:22 2014
@@ -317,7 +317,7 @@ public abstract class PDFont implements 
      * @param code character code
      * @return Unicode character(s)
      */
-    public String toUnicode(int code)
+    public String toUnicode(int code) throws IOException
     {
         // if the font dictionary contains a ToUnicode CMap, use that CMap
         if (toUnicodeCMap != null)

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=1626296&r1=1626295&r2=1626296&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 Fri
Sep 19 18:57:22 2014
@@ -132,6 +132,12 @@ public abstract class PDSimpleFont exten
             this.encoding = readEncodingFromFont();
         }
 
+        // TTFs may have null encoding, but if they're non-symbolic then we know it's Adobe
encoding
+        if (this.encoding == null && !isSymbolic())
+        {
+            this.encoding = StandardEncoding.INSTANCE;
+        }
+
         // assign the glyph list based on the font
         if ("ZapfDingbats".equals(getBaseFont()))
         {
@@ -222,7 +228,7 @@ public abstract class PDSimpleFont exten
     }
 
     @Override
-    public String toUnicode(int code)
+    public String toUnicode(int code) throws IOException
     {
         // first try to use a ToUnicode CMap
         String unicode = super.toUnicode(code);

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=1626296&r1=1626295&r2=1626296&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 Fri
Sep 19 18:57:22 2014
@@ -244,9 +244,9 @@ public class PDTrueTypeFont extends PDSi
                     String unicode = GlyphList.DEFAULT.toUnicode(name);
                     if (unicode != null)
                     {
-                        gid = unicode.codePointAt(0);
+                        int uni = unicode.codePointAt(0);
+                        gid = cmapWinUnicode.getGlyphId(uni);
                     }
-                    gid = cmapWinUnicode.getGlyphId(gid);
                 }
 
                 // (1, 0) - (Macintosh, Roman)

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java?rev=1626296&r1=1626295&r2=1626296&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java Fri
Sep 19 18:57:22 2014
@@ -237,7 +237,7 @@ public class PDType0Font extends PDFont
     }
 
     @Override
-    public String toUnicode(int code)
+    public String toUnicode(int code) throws IOException
     {
         // try to use a ToUnicode CMap
         String unicode = super.toUnicode(code);



Mime
View raw message