You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2017/06/19 17:03:13 UTC

svn commit: r1799233 - /pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java

Author: tilman
Date: Mon Jun 19 17:03:12 2017
New Revision: 1799233

URL: http://svn.apache.org/viewvc?rev=1799233&view=rev
Log:
PDFBOX-2852: use switch

Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java?rev=1799233&r1=1799232&r2=1799233&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java Mon Jun 19 17:03:12 2017
@@ -740,17 +740,14 @@ public class CFFParser
         int format = dataInput.readCard8();
         int baseFormat = format & 0x7f;
 
-        if (baseFormat == 0)
+        switch (baseFormat)
         {
-            return readFormat0Encoding(dataInput, charset, format);
-        }
-        else if (baseFormat == 1)
-        {
-            return readFormat1Encoding(dataInput, charset, format);
-        }
-        else
-        {
-            throw new IllegalArgumentException();
+            case 0:
+                return readFormat0Encoding(dataInput, charset, format);
+            case 1:
+                return readFormat1Encoding(dataInput, charset, format);
+            default:
+                throw new IllegalArgumentException();
         }
     }
 
@@ -827,17 +824,14 @@ public class CFFParser
     private static FDSelect readFDSelect(CFFDataInput dataInput, int nGlyphs, CFFCIDFont ros) throws IOException
     {
         int format = dataInput.readCard8();
-        if (format == 0)
-        {
-            return readFormat0FDSelect(dataInput, format, nGlyphs, ros);
-        }
-        else if (format == 3)
-        {
-            return readFormat3FDSelect(dataInput, format, nGlyphs, ros);
-        }
-        else
+        switch (format)
         {
-            throw new IllegalArgumentException();
+            case 0:
+                return readFormat0FDSelect(dataInput, format, nGlyphs, ros);
+            case 3:
+                return readFormat3FDSelect(dataInput, format, nGlyphs, ros);
+            default:
+                throw new IllegalArgumentException();
         }
     }
 
@@ -996,21 +990,16 @@ public class CFFParser
             throws IOException
     {
         int format = dataInput.readCard8();
-        if (format == 0)
-        {
-            return readFormat0Charset(dataInput, format, nGlyphs, isCIDFont);
-        }
-        else if (format == 1)
-        {
-            return readFormat1Charset(dataInput, format, nGlyphs, isCIDFont);
-        }
-        else if (format == 2)
+        switch (format)
         {
-            return readFormat2Charset(dataInput, format, nGlyphs, isCIDFont);
-        }
-        else
-        {
-            throw new IllegalArgumentException();
+            case 0:
+                return readFormat0Charset(dataInput, format, nGlyphs, isCIDFont);
+            case 1:
+                return readFormat1Charset(dataInput, format, nGlyphs, isCIDFont);
+            case 2:
+                return readFormat2Charset(dataInput, format, nGlyphs, isCIDFont);
+            default:
+                throw new IllegalArgumentException();
         }
     }
 
@@ -1315,7 +1304,7 @@ public class CFFParser
         protected EmptyCharset(int numCharStrings)
         {
             super(true);
-            addCID(0 ,0); // .notdef
+            addCID(0, 0); // .notdef
             
             // Adobe Reader treats CID as GID, PDFBOX-2571 p11.
             for (int i = 1; i <= numCharStrings; i++)