pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1545349 - in /pdfbox/branches/1.8: pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ preflight/src/main/java/org/apache/pdfbox/preflight/font/
Date Mon, 25 Nov 2013 17:43:32 GMT
Author: lehmi
Date: Mon Nov 25 17:43:31 2013
New Revision: 1545349

URL: http://svn.apache.org/r1545349
Log:
PDFBOX-1663: changed data type to avoid broken API

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/PDTrueTypeFont.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1AfmPfbFont.java
    pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.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=1545349&r1=1545348&r2=1545349&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 Mon
Nov 25 17:43:31 2013
@@ -49,15 +49,6 @@ import org.apache.pdfbox.util.ResourceLo
 import java.awt.Graphics;
 import java.awt.geom.AffineTransform;
 
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 /**
  * This is the base class for all PDF fonts.
  *
@@ -106,7 +97,7 @@ public abstract class PDFont implements 
     /**
      *  A list a floats representing the widths.
      */
-    private List<Integer> widths = null;
+    private List<Float> widths = null;
 
     /**
      * The static map of the default Adobe font metrics.
@@ -790,15 +781,16 @@ public abstract class PDFont implements 
      * The widths of the characters.  This will be null for the standard 14 fonts.
      *
      * @return The widths of the characters.
+     *
      */
-    public List<Integer> getWidths()
+    public List<Float> getWidths()
     {
         if (widths == null)
         {
             COSArray array = (COSArray)font.getDictionaryObject( COSName.WIDTHS );
             if (array != null)
             {
-                widths = COSArrayList.convertIntegerCOSArrayToList(array);
+                widths = COSArrayList.convertFloatCOSArrayToList(array);
             }
         }
         return widths;
@@ -809,7 +801,7 @@ public abstract class PDFont implements 
      *
      * @param widthsList The widths of the character codes.
      */
-    public void setWidths(List<Integer> widthsList)
+    public void setWidths(List<Float> widthsList)
     {
         widths = widthsList;
         font.setItem( COSName.WIDTHS, COSArrayList.converterToCOSArray( widths ) );

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java?rev=1545349&r1=1545348&r2=1545349&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
Mon Nov 25 17:43:31 2013
@@ -383,14 +383,14 @@ public class PDTrueTypeFont extends PDSi
             // instead of an array containing the same value for every glyphid 
             boolean isMonospaced = fd.isFixedPitch();
             int nWidths=lastChar-firstChar+1;
-            List<Integer> widths = new ArrayList<Integer>(nWidths);
+            List<Float> widths = new ArrayList<Float>(nWidths);
             // use the first width as default
             // proportional fonts -> width of the .notdef character
             // monospaced-fonts -> the first width
             int defaultWidth = Math.round(widthValues[0] * scaling);
             for (int i = 0; i < nWidths; i++)
             {
-                widths.add(defaultWidth);
+                widths.add((float)defaultWidth);
             }
             // Encoding singleton to have acces to the chglyph name to
             // unicode cpoint point mapping of Adobe's glyphlist.txt
@@ -412,11 +412,11 @@ public class PDTrueTypeFont extends PDSi
                 {
                     if (isMonospaced)
                     {
-                        widths.set(e.getKey().intValue() - firstChar, defaultWidth);
+                        widths.set(e.getKey().intValue() - firstChar, (float)defaultWidth);
                     }
                     else
                     {
-                        widths.set(e.getKey().intValue() - firstChar, Math.round(widthValues[gid]
* scaling));
+                        widths.set(e.getKey().intValue() - firstChar, (float)Math.round(widthValues[gid]
* scaling));
                     }
                 }
             }

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1AfmPfbFont.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1AfmPfbFont.java?rev=1545349&r1=1545348&r2=1545349&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1AfmPfbFont.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1AfmPfbFont.java
Mon Nov 25 17:43:31 2013
@@ -143,12 +143,12 @@ public class PDType1AfmPfbFont extends P
         List<CharMetric> listmetric = metric.getCharMetrics();
         Encoding encoding = getFontEncoding();
         int maxWidths = 256;
-        List<Integer> widths = new ArrayList<Integer>(maxWidths);
+        List<Float> widths = new ArrayList<Float>(maxWidths);
         int zero = 250;
         Iterator<CharMetric> iter = listmetric.iterator();
         for (int i = 0; i < maxWidths; i++)
         {
-            widths.add(zero);
+            widths.add((float)zero);
         }
         while (iter.hasNext())
         {
@@ -161,13 +161,13 @@ public class PDType1AfmPfbFont extends P
                 if (m.getWx() > 0)
                 {
                     int width = Math.round(m.getWx());
-                    widths.set(n, width);
+                    widths.set(n, (float)width);
                     // germandbls has 2 character codes !! Don't ask me why .....
                     // StandardEncoding = 0373 = 251
                     // WinANSIEncoding = 0337 = 223
                     if (m.getName().equals("germandbls") && n != 223)
                     {
-                        widths.set(0337, width);
+                        widths.set(0337, (float)width);
                     }
                 }
             }

Modified: pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java?rev=1545349&r1=1545348&r2=1545349&view=diff
==============================================================================
--- pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java
(original)
+++ pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/font/Type3FontValidator.java
Mon Nov 25 17:43:31 2013
@@ -276,7 +276,7 @@ public class Type3FontValidator extends 
      */
     private void checkCharProcsAndMetrics() throws ValidationException
     {
-        List<Integer> widths = font.getWidths();
+        List<Float> widths = font.getWidths();
         if (widths == null || widths.isEmpty())
         {
             this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,



Mime
View raw message