You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2018/09/27 17:59:02 UTC

svn commit: r1842132 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java

Author: tilman
Date: Thu Sep 27 17:59:02 2018
New Revision: 1842132

URL: http://svn.apache.org/viewvc?rev=1842132&view=rev
Log:
PDFBOX-4322: treat identity ToUnicode streams that are empty as identity

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java?rev=1842132&r1=1842131&r2=1842132&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java Thu Sep 27 17:59:02 2018
@@ -440,13 +440,16 @@ public abstract class PDFont implements
         // if the font dictionary containsName a ToUnicode CMap, use that CMap
         if (toUnicodeCMap != null)
         {
-            if (toUnicodeCMap.getName() != null && toUnicodeCMap.getName().startsWith("Identity-") && 
-                    dict.getDictionaryObject(COSName.TO_UNICODE) instanceof COSName)
+            if (toUnicodeCMap.getName() != null && 
+                toUnicodeCMap.getName().startsWith("Identity-") && 
+                    (dict.getDictionaryObject(COSName.TO_UNICODE) instanceof COSName ||
+                     !toUnicodeCMap.hasUnicodeMappings()))
             {
                 // handle the undocumented case of using Identity-H/V as a ToUnicode CMap, this
                 // isn't actually valid as the Identity-x CMaps are code->CID maps, not
                 // code->Unicode maps. See sample_fonts_solidconvertor.pdf for an example.
                 // PDFBOX-3123: do this only if the /ToUnicode entry is a name
+                // PDFBOX-4322: identity streams are OK too
                 return new String(new char[] { (char) code });
             }
             else