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 2024/08/30 18:10:23 UTC

svn commit: r1920307 - /pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java

Author: tilman
Date: Fri Aug 30 18:10:23 2024
New Revision: 1920307

URL: http://svn.apache.org/viewvc?rev=1920307&view=rev
Log:
PDFBOX-5873: split long method

Modified:
    pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java

Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java?rev=1920307&r1=1920306&r2=1920307&view=diff
==============================================================================
--- pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java (original)
+++ pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ExtractTTFFonts.java Fri Aug 30 18:10:23 2024
@@ -199,6 +199,12 @@ public final class ExtractTTFFonts
             return;
         }
 
+        processResourcesFonts(resources, addKey, prefix);
+        processNestedResources(resources, prefix, addKey);
+    }
+
+    private void processResourcesFonts(PDResources resources, boolean addKey, String prefix) throws IOException
+    {
         for (COSName key : resources.getFontNames())
         {
             PDFont font = resources.getFont(key);
@@ -216,7 +222,7 @@ public final class ExtractTTFFonts
             // write the font
             if (font instanceof PDTrueTypeFont)
             {
-                String name = null;
+                String name;
                 if (addKey)
                 {
                     name = getUniqueFileName(prefix + "_" + key, "ttf");
@@ -232,7 +238,7 @@ public final class ExtractTTFFonts
                 PDCIDFont descendantFont = ((PDType0Font) font).getDescendantFont();
                 if (descendantFont instanceof PDCIDFontType2)
                 {
-                    String name = null;
+                    String name;
                     if (addKey)
                     {
                         name = getUniqueFileName(prefix + "_" + key, "ttf");
@@ -245,7 +251,11 @@ public final class ExtractTTFFonts
                 }
             }
         }
+    }
 
+    private void processNestedResources(PDResources resources, String prefix, boolean addKey)
+            throws IOException
+    {
         for (COSName name : resources.getXObjectNames())
         {
             PDXObject xobject = resources.getXObject(name);