pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1642458 - in /pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font: PDFont.java PDType1CFont.java PDType1Font.java
Date Sat, 29 Nov 2014 17:49:09 GMT
Author: lehmi
Date: Sat Nov 29 17:49:08 2014
New Revision: 1642458

URL: http://svn.apache.org/r1642458
Log:
PDFBOX-2377: revert changes committed in 1627810

Modified:
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java?rev=1642458&r1=1642457&r2=1642458&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java Sat
Nov 29 17:49:08 2014
@@ -570,18 +570,14 @@ public abstract class PDFont implements 
     {
         for( int i=0; i<256; i++ )
         {
-            // ISO-8859-1 doesn't support the whole range
-            if (i >= 32 && (i < 127 || i > 159))
+            try
             {
-                try
-                {
-                    SINGLE_CHAR_STRING[i] = new String( new byte[] {(byte)i}, "ISO-8859-1"
);
-                }
-                catch (UnsupportedEncodingException e)
-                {
-                    // Nothing should happen here
-                    LOG.error(e,e);
-                }
+                SINGLE_CHAR_STRING[i] = new String( new byte[] {(byte)i}, "ISO-8859-1" );
+            }
+            catch (UnsupportedEncodingException e)
+            {
+                // Nothing should happen here
+                LOG.error(e,e);
             }
             for( int j=0; j<256; j++ )
             {
@@ -598,7 +594,7 @@ public abstract class PDFont implements 
         }
     }
 
-    protected String getStringFromArray( byte[] c, int offset, int length ) throws IOException
+    private static String getStringFromArray( byte[] c, int offset, int length ) throws IOException
     {
         String retval = null;
         if( length == 1 )

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java?rev=1642458&r1=1642457&r2=1642458&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
Sat Nov 29 17:49:08 2014
@@ -92,6 +92,8 @@ public class PDType1CFont extends PDSimp
 
     private static final byte[] SPACE_BYTES = {(byte)32};
 
+    private final int charOffset;
+    
     /**
      * Constructor.
      * @param fontDictionary the corresponding dictionary
@@ -99,6 +101,7 @@ public class PDType1CFont extends PDSimp
     public PDType1CFont( COSDictionary fontDictionary ) throws IOException
     {
         super( fontDictionary );
+        charOffset = getFirstChar() > -1 ? getFirstChar() - 1 : 0; 
         load();
     }
 
@@ -121,7 +124,11 @@ public class PDType1CFont extends PDSimp
     {
         int code = getCodeFromArray(bytes, offset, length);
         String character = null;
-        if (codeToSID.containsKey(code))
+        if (charOffset > 0)
+        {
+            code -= charOffset;
+        }
+        else if (codeToSID.containsKey(code))
         {
             code = codeToSID.get(code);
         }

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java?rev=1642458&r1=1642457&r2=1642458&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
Sat Nov 29 17:49:08 2014
@@ -463,13 +463,11 @@ public class PDType1Font extends PDSimpl
     {
         if (type1CFont != null && getFontEncoding() == null)
         {
-            // check for ASCII values >= 32
-            if (length == 1 && c[offset] >= 32)
+            String character = type1CFont.encode(c, offset, length);
+            if (character != null)
             {
-                return getStringFromArray( c, offset, length );
+                return character;
             }
-            // handle values < 32 and negative byte values (int > 127)
-            return type1CFont.encode(c, offset, length);
         }
         return super.encode(c, offset, length);
     }



Mime
View raw message