pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1646693 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font: PDCIDFont.java PDFont.java PDType0Font.java
Date Fri, 19 Dec 2014 12:36:28 GMT
Author: tilman
Date: Fri Dec 19 12:36:28 2014
New Revision: 1646693

URL: http://svn.apache.org/r1646693
Log:
PDFBOX-2576: instanceof is never null

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java?rev=1646693&r1=1646692&r2=1646693&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFont.java Fri Dec
19 12:36:28 2014
@@ -45,8 +45,8 @@ public abstract class PDCIDFont implemen
     private Map<Integer, Float> widths;
     private float defaultWidth;
 
-    private Map<Integer, Float> verticalDisplacementY = new HashMap<Integer, Float>();
// w1y
-    private Map<Integer, Vector> positionVectors = new HashMap<Integer, Vector>();
    // v
+    private final Map<Integer, Float> verticalDisplacementY = new HashMap<Integer,
Float>(); // w1y
+    private final Map<Integer, Vector> positionVectors = new HashMap<Integer, Vector>();
    // v
     private float[] dw2;
 
     protected final COSDictionary dict;

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=1646693&r1=1646692&r2=1646693&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 Fri Dec 19
12:36:28 2014
@@ -312,6 +312,7 @@ public abstract class PDFont implements
      * @return The width is in 1000 unit of text space, ie 333 or 777
      */
     // todo: this method is highly suspicious, the average glyph width is not usually a good
metric
+    @Override
     public float getAverageFontWidth()
     {
         float average;

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java?rev=1646693&r1=1646692&r2=1646693&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java Fri
Dec 19 12:36:28 2014
@@ -118,34 +118,30 @@ public class PDType0Font extends PDFont
     private void readEncoding() throws IOException
     {
         COSBase encoding = dict.getDictionaryObject(COSName.ENCODING);
-        if (encoding != null)
+        if (encoding instanceof COSName)
         {
-            if (encoding instanceof COSName)
+            // predefined CMap
+            COSName encodingName = (COSName) encoding;
+            cMap = CMapManager.getPredefinedCMap(encodingName.getName());
+            if (cMap != null)
             {
-                // predefined CMap
-                COSName encodingName = (COSName)encoding;
-                cMap = CMapManager.getPredefinedCMap(encodingName.getName());
-                if (cMap != null)
-                {
-                    isCMapPredefined = true;
-                    return;
-                }
-                else
-                {
-                    throw new IOException("Missing required CMap");
-                }
+                isCMapPredefined = true;
             }
             else
             {
-                cMap = readCMap(encoding);
-                if (cMap == null)
-                {
-                    throw new IOException("Missing required CMap");
-                }
-                else if (!cMap.hasCIDMappings())
-                {
-                    LOG.warn("Invalid Encoding CMap in font " + getName());
-                }
+                throw new IOException("Missing required CMap");
+            }
+        }
+        else if (encoding != null)
+        {
+            cMap = readCMap(encoding);
+            if (cMap == null)
+            {
+                throw new IOException("Missing required CMap");
+            }
+            else if (!cMap.hasCIDMappings())
+            {
+                LOG.warn("Invalid Encoding CMap in font " + getName());
             }
         }
     }
@@ -169,7 +165,7 @@ public class PDType0Font extends PDFont
 
             // get the encoding CMap
             COSBase encoding = dict.getDictionaryObject(COSName.ENCODING);
-            if (encoding != null && encoding instanceof COSName)
+            if (encoding instanceof COSName)
             {
                 cMapName = ((COSName)encoding).getName();
             }



Mime
View raw message