pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1713283 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
Date Sun, 08 Nov 2015 19:48:30 GMT
Author: tilman
Date: Sun Nov  8 19:48:30 2015
New Revision: 1713283

URL: http://svn.apache.org/viewvc?rev=1713283&view=rev
Log:
PDFBOX-2711: don't log twice (like in PDSimpleFont)

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java

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=1713283&r1=1713282&r2=1713283&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 Sun
Nov  8 19:48:30 2015
@@ -20,6 +20,8 @@ import java.awt.geom.GeneralPath;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Set;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.fontbox.cmap.CMap;
@@ -48,6 +50,7 @@ public class PDType0Font extends PDFont
     private boolean isCMapPredefined;
     private boolean isDescendantCJK;
     private PDCIDFontType2Embedder embedder;
+    private final Set<Integer> noUnicode = new HashSet<Integer>(); 
     
     /**
     * Loads a TTF to be embedded into a document as a Type 0 font.
@@ -421,9 +424,14 @@ public class PDType0Font extends PDFont
         }
         else
         {
-            // if no value has been produced, there is no way to obtain Unicode for the character.
-            String cid = "CID+" + codeToCID(code);
-            LOG.warn("No Unicode mapping for " + cid + " (" + code + ") in font " + getName());
+            if (LOG.isWarnEnabled() && !noUnicode.contains(code))
+            {
+                // if no value has been produced, there is no way to obtain Unicode for the
character.
+                String cid = "CID+" + codeToCID(code);
+                LOG.warn("No Unicode mapping for " + cid + " (" + code + ") in font " + getName());
+                // we keep track of which warnings have been issued, so we don't log multiple
times
+                noUnicode.add(code);
+            }
             return null;
         }
     }



Mime
View raw message