pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1592577 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font: PDType1CFont.java PDType1Font.java
Date Mon, 05 May 2014 17:21:07 GMT
Author: lehmi
Date: Mon May  5 17:21:06 2014
New Revision: 1592577

URL: http://svn.apache.org/r1592577
Log:
PDFBOX-2058: fall back to PDFont.encode if the type1c doesn't provide a suitable mapping

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java?rev=1592577&r1=1592576&r2=1592577&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java Mon
May  5 17:21:06 2014
@@ -345,15 +345,13 @@ public class PDType1CFont extends PDSimp
             {
                 character = Encoding.getCharacterForName(name);
             }
-            if (character == null)
+            codeToSID.put(mapping.getCode(), sid);
+            sidToName.put(sid, name);
+            if (character != null)
             {
-                name = "uni" + hexString(sid, 4);
-                character = String.valueOf(Character.toChars(sid));
+                sidToCharacter.put(sid, character);
+                characterToSID.put(character, sid);
             }
-            sidToName.put(sid, name);
-            sidToCharacter.put(sid, character);
-            characterToSID.put(character, sid);
-            codeToSID.put(mapping.getCode(), sid);
         }
     }
 
@@ -392,16 +390,6 @@ public class PDType1CFont extends PDSimp
         return null;
     }
 
-    private static String hexString(int code, int length)
-    {
-        String string = Integer.toHexString(code).toUpperCase();
-        while (string.length() < length)
-        {
-            string = ("0" + string);
-        }
-        return string;
-    }
-
     private FontMetric prepareFontMetric(CFFFont font) throws IOException
     {
         byte[] afmBytes = AFMFormatter.format(font);

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java?rev=1592577&r1=1592576&r2=1592577&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java Mon
May  5 17:21:06 2014
@@ -519,12 +519,13 @@ public class PDType1Font extends PDSimpl
     {
         if (type1CFont != null && getFontEncoding() == null)
         {
-            return type1CFont.encode(c, offset, length);
-        }
-        else
-        {
-            return super.encode(c, offset, length);
+            String character = type1CFont.encode(c, offset, length);
+            if (character != null)
+            {
+                return character;
+            }
         }
+        return super.encode(c, offset, length);
     }
 
     /**



Mime
View raw message