You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ja...@apache.org on 2014/08/27 00:54:07 UTC

svn commit: r1620757 - /pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java

Author: jahewson
Date: Tue Aug 26 22:54:07 2014
New Revision: 1620757

URL: http://svn.apache.org/r1620757
Log:
PDFBOX-2262: Allow overriding of CIDFont widths

Modified:
    pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java

Modified: pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java?rev=1620757&r1=1620756&r2=1620757&view=diff
==============================================================================
--- pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java (original)
+++ pdfbox/branches/no-awt/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java Tue Aug 26 22:54:07 2014
@@ -184,9 +184,19 @@ public abstract class PDCIDFont implemen
      */
     public float getWidth(int code) throws IOException
     {
-        // These widths shall be consistent with the actual widths given in the CIDFont program.
-        // Note: PDFBOX-1422 contains an example showing that CIDFont widths are not overridden
-        return getWidthFromFont(code);
+        // these widths are supposed to be consistent with the actual widths given in the CIDFont
+        // program, but PDFBOX-563 shows that when they are not, Acrobat overrides the embedded
+        // font widths with the widths given in the font dictionary
+
+        int cid = codeToCID(code);
+        if (cid < widths.size())
+        {
+            return widths.get(cid);
+        }
+        else
+        {
+            return getWidthFromFont(code);
+        }
     }
 
     /**