pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1600697 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
Date Thu, 05 Jun 2014 16:48:03 GMT
Author: lehmi
Date: Thu Jun  5 16:48:02 2014
New Revision: 1600697

URL: http://svn.apache.org/r1600697
Log:
PDFBOX-62: don't repeat looking for widths if the font doesn't provide any

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java?rev=1600697&r1=1600696&r2=1600697&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDFont.java Thu Jun 
5 16:48:02 2014
@@ -87,6 +87,8 @@ public abstract class PDFont implements 
 
     private boolean hasToUnicode = false;
 
+    private boolean widthsAreMissing = false;
+
     protected static Map<String, CMap> cmapObjects = Collections.synchronizedMap(new
HashMap<String, CMap>());
 
     /**
@@ -681,13 +683,17 @@ public abstract class PDFont implements 
      */
     public List<Integer> getWidths()
     {
-        if (widths == null)
+        if (widths == null && !widthsAreMissing)
         {
             COSArray array = (COSArray) font.getDictionaryObject(COSName.WIDTHS);
             if (array != null)
             {
                 widths = COSArrayList.convertIntegerCOSArrayToList(array);
             }
+            else
+            {
+                widthsAreMissing = true;
+            }
         }
         return widths;
     }
@@ -771,10 +777,13 @@ public abstract class PDFont implements 
         if (charCode >= firstChar && charCode <= lastChar)
         {
             // maybe the font doesn't provide any widths
-            getWidths();
-            if (widths != null)
+            if (!widthsAreMissing)
             {
-                width = widths.get(charCode - firstChar).floatValue();
+                getWidths();
+                if (widths != null)
+                {
+                    width = widths.get(charCode - firstChar).floatValue();
+                }
             }
         }
         else



Mime
View raw message