pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1622305 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox: encoding/DictionaryEncoding.java pdmodel/font/PDSimpleFont.java pdmodel/font/PDTrueTypeFont.java
Date Wed, 03 Sep 2014 17:50:41 GMT
Author: jahewson
Date: Wed Sep  3 17:50:41 2014
New Revision: 1622305

URL: http://svn.apache.org/r1622305
Log:
PDFBOX-2312: Allow symbolic TTFs to not use an Encoding dictionary

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/DictionaryEncoding.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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/DictionaryEncoding.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/DictionaryEncoding.java?rev=1622305&r1=1622304&r2=1622305&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/DictionaryEncoding.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/encoding/DictionaryEncoding.java Wed
Sep  3 17:50:41 2014
@@ -77,9 +77,12 @@ public class DictionaryEncoding extends 
         }
         else
         {
-            // and for a symbolic font, it is the font's built-in encoding."
-            baseEncoding = builtIn;
-            if (builtIn == null)
+            // and for a symbolic font, it is the font's built-in encoding.
+            if (builtIn != null)
+            {
+                baseEncoding = builtIn;
+            }
+            else
             {
                 throw new IllegalArgumentException("Built-in Encoding required for symbolic
font");
             }

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=1622305&r1=1622304&r2=1622305&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 Wed
Sep  3 17:50:41 2014
@@ -114,7 +114,16 @@ public abstract class PDSimpleFont exten
                 {
                     symbolic = builtIn != null;
                 }
-                this.encoding = new DictionaryEncoding(encodingDict, !symbolic, builtIn);
+
+                if (builtIn == null && !encodingDict.containsKey(COSName.BASE_ENCODING)
&& symbolic)
+                {
+                    // TTF built-in encoding is handled by PDTrueTypeFont#codeToGID
+                    this.encoding = null;
+                }
+                else
+                {
+                    this.encoding = new DictionaryEncoding(encodingDict, !symbolic, builtIn);
+                }
             }
         }
         else

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=1622305&r1=1622304&r2=1622305&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 Wed
Sep  3 17:50:41 2014
@@ -138,7 +138,8 @@ public class PDTrueTypeFont extends PDSi
     @Override
     protected Encoding readEncodingFromFont() throws IOException
     {
-        // TTF fonts don't have PostScript Encoding vectors
+        // for symbolic fonts the (3, 0) (Windows, Symbol) cmap is the font's built-in encoding
+        // but this is handled by codeToGID
         return null;
     }
 
@@ -215,9 +216,9 @@ public class PDTrueTypeFont extends PDSi
         extractCmapTable();
         int gid = 0;
 
-        if (getEncoding() != null && !isSymbolic()) // non-symbolic
+        if (!isSymbolic()) // non-symbolic
         {
-            String name = getEncoding().getName(code);
+            String name = encoding.getName(code);
             if (name.equals(".notdef"))
             {
                 return 0;



Mime
View raw message