pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1751600 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font: PDSimpleFont.java encoding/DictionaryEncoding.java
Date Wed, 06 Jul 2016 05:39:41 GMT
Author: tilman
Date: Wed Jul  6 05:39:41 2016
New Revision: 1751600

URL: http://svn.apache.org/viewvc?rev=1751600&view=rev
Log:
PDFBOX-3403: revert 1750561 for lack of consensus

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/encoding/DictionaryEncoding.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=1751600&r1=1751599&r2=1751600&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
Jul  6 05:39:41 2016
@@ -366,10 +366,6 @@ public abstract class PDSimpleFont exten
                 // we also require that the differences are actually different, see PDFBOX-1900
with
                 // the file from PDFBOX-2192 on Windows
                 Encoding baseEncoding = dictionary.getBaseEncoding();
-                if (baseEncoding == null)
-                {
-                    return false;
-                }
                 for (Map.Entry<Integer, String> entry : dictionary.getDifferences().entrySet())
                 {
                     if (!entry.getValue().equals(baseEncoding.getName(entry.getKey())))

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/DictionaryEncoding.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/DictionaryEncoding.java?rev=1751600&r1=1751599&r2=1751600&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/DictionaryEncoding.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/DictionaryEncoding.java
Wed Jul  6 05:39:41 2016
@@ -19,8 +19,6 @@ package org.apache.pdfbox.pdmodel.font.e
 
 import java.util.HashMap;
 import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
@@ -34,7 +32,6 @@ import org.apache.pdfbox.cos.COSNumber;
  */
 public class DictionaryEncoding extends Encoding
 {
-    private static final Log LOG = LogFactory.getLog(DictionaryEncoding.class);
     private final COSDictionary encoding;
     private final Encoding baseEncoding;
     private final Map<Integer, String> differences = new HashMap<Integer, String>();
@@ -62,14 +59,11 @@ public class DictionaryEncoding extends
 
         if (this.baseEncoding == null)
         {
-            LOG.error("Invalid encoding: " + baseEncoding);
+            throw new IllegalArgumentException("Invalid encoding: " + baseEncoding);
         }
         
-        if (this.baseEncoding != null)
-        {
-            codeToName.putAll(this.baseEncoding.codeToName);
-            inverted.putAll(this.baseEncoding.inverted);
-        }
+        codeToName.putAll(this.baseEncoding.codeToName);
+        inverted.putAll(this.baseEncoding.inverted);
         applyDifferences();
     }
 
@@ -100,7 +94,7 @@ public class DictionaryEncoding extends
         if (encoding.containsKey(COSName.BASE_ENCODING))
         {
             COSName name = encoding.getCOSName(COSName.BASE_ENCODING);
-            base = Encoding.getInstance(name);
+            base = Encoding.getInstance(name); // may be null
         }
 
         if (base == null)
@@ -119,33 +113,26 @@ public class DictionaryEncoding extends
                 }
                 else
                 {
-                    LOG.error("Symbolic fonts must have a built-in encoding");
+                    throw new IllegalArgumentException("Symbolic fonts must have a built-in
" + 
+                                                       "encoding");
                 }
             }
         }
         baseEncoding = base;
 
-        if (baseEncoding != null)
-        {
-            codeToName.putAll(baseEncoding.codeToName);
-            inverted.putAll(baseEncoding.inverted);
-        }
+        codeToName.putAll(baseEncoding.codeToName);
+        inverted.putAll(baseEncoding.inverted);
         applyDifferences();
     }
 
     private void applyDifferences()
     {
         // now replace with the differences
-        COSBase base = encoding.getDictionaryObject(COSName.DIFFERENCES);
-        if (!(base instanceof COSArray))
-        {
-            return;
-        }
-        COSArray diffArray = (COSArray) base;
+        COSArray differences = (COSArray)encoding.getDictionaryObject( COSName.DIFFERENCES
);
         int currentIndex = -1;
-        for (int i = 0; i < diffArray.size(); i++)
+        for( int i=0; differences != null && i<differences.size(); i++ )
         {
-            COSBase next = diffArray.getObject(i);
+            COSBase next = differences.getObject( i );
             if( next instanceof COSNumber)
             {
                 currentIndex = ((COSNumber)next).intValue();
@@ -161,7 +148,7 @@ public class DictionaryEncoding extends
     }
 
     /**
-     * Returns the base encoding. Will be null for Type 3 fonts or if the encoding is missing
or invalid.
+     * Returns the base encoding. Will be null for Type 3 fonts.
      */
     public Encoding getBaseEncoding()
     {



Mime
View raw message