pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1700894 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding: DictionaryEncoding.java Encoding.java
Date Wed, 02 Sep 2015 20:32:58 GMT
Author: jahewson
Date: Wed Sep  2 20:32:58 2015
New Revision: 1700894

URL: http://svn.apache.org/r1700894
Log:
PDFBOX-2951: Fix issue with Encoding caching names before Differences have been applied

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/DictionaryEncoding.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/Encoding.java

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=1700894&r1=1700893&r2=1700894&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 Sep  2 20:32:58 2015
@@ -60,7 +60,6 @@ public class DictionaryEncoding extends
         }
         
         codeToName.putAll( this.baseEncoding.codeToName );
-        names.addAll( this.baseEncoding.names );
         applyDifferences();
     }
 
@@ -118,7 +117,6 @@ public class DictionaryEncoding extends
         baseEncoding = base;
 
         codeToName.putAll( baseEncoding.codeToName );
-        names.addAll( baseEncoding.names );
         applyDifferences();
     }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/Encoding.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/Encoding.java?rev=1700894&r1=1700893&r2=1700894&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/Encoding.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/Encoding.java
Wed Sep  2 20:32:58 2015
@@ -21,7 +21,6 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 
@@ -59,7 +58,7 @@ public abstract class Encoding implement
     }
 
     protected final Map<Integer, String> codeToName = new HashMap<Integer, String>();
-    protected final Set<String> names = new HashSet<String>();
+    private Set<String> names;
 
     /**
      * Returns an unmodifiable view of the Code2Name mapping.
@@ -80,7 +79,6 @@ public abstract class Encoding implement
     protected void add(int code, String name)
     {
         codeToName.put(code, name);
-        names.add(name);
     }
 
     /**
@@ -90,6 +88,13 @@ public abstract class Encoding implement
      */
     public boolean contains(String name)
     {
+        // we have to wait until all add() calls are done before building the name cache
+        // otherwise /Differences won't be accounted for
+        if (names == null)
+        {
+            names = new HashSet<String>();
+            names.addAll(codeToName.values());
+        }
         return names.contains(name);
     }
 



Mime
View raw message