pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1621495 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font: ExternalFonts.java FileSystemFontProvider.java FontProvider.java
Date Sat, 30 Aug 2014 16:59:15 GMT
Author: jahewson
Date: Sat Aug 30 16:59:15 2014
New Revision: 1621495

URL: http://svn.apache.org/r1621495
Log:
PDFBOX-2262: Added logging for missing fallback fonts

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ExternalFonts.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontProvider.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ExternalFonts.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ExternalFonts.java?rev=1621495&r1=1621494&r2=1621495&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ExternalFonts.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ExternalFonts.java Sat
Aug 30 16:59:15 2014
@@ -23,6 +23,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.fontbox.cff.CFFCIDFont;
 import org.apache.fontbox.cff.CFFFont;
 import org.apache.fontbox.cff.CFFType1Font;
@@ -45,6 +47,7 @@ public final class ExternalFonts
         private static final FontProvider INSTANCE = new FileSystemFontProvider();
     }
 
+    private static final Log log = LogFactory.getLog(ExternalFonts.class);
     private static FontProvider fontProvider;
 
     /**
@@ -238,6 +241,12 @@ public final class ExternalFonts
         TrueTypeFont ttf = getTrueTypeFont(fontName);
         if (ttf == null)
         {
+            String message = fontProvider.toDebugString();
+            if (message != null)
+            {
+                log.error("No fallback font for '" + fontName + "', dumping debug information:");
+                log.error(message);
+            }
             throw new IllegalStateException("No fonts available on the system for " + fontName);
         }
         return ttf;

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java?rev=1621495&r1=1621494&r2=1621495&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FileSystemFontProvider.java
Sat Aug 30 16:59:15 2014
@@ -299,4 +299,35 @@ final class FileSystemFontProvider imple
         }
         return null;
     }
+
+    @Override
+    public String toDebugString()
+    {
+        StringBuilder sb = new StringBuilder();
+        for (Map.Entry<String, File> entry : ttfFontFiles.entrySet())
+        {
+            sb.append("TTF: ");
+            sb.append(entry.getKey());
+            sb.append(": ");
+            sb.append(entry.getValue().getPath());
+            sb.append('\n');
+        }
+        for (Map.Entry<String, File> entry : cffFontFiles.entrySet())
+        {
+            sb.append("OTF: ");
+            sb.append(entry.getKey());
+            sb.append(": ");
+            sb.append(entry.getValue().getPath());
+            sb.append('\n');
+        }
+        for (Map.Entry<String, File> entry : type1FontFiles.entrySet())
+        {
+            sb.append("PFB: ");
+            sb.append(entry.getKey());
+            sb.append(": ");
+            sb.append(entry.getValue().getPath());
+            sb.append('\n');
+        }
+        return sb.toString();
+    }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontProvider.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontProvider.java?rev=1621495&r1=1621494&r2=1621495&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontProvider.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontProvider.java Sat
Aug 30 16:59:15 2014
@@ -50,4 +50,10 @@ public interface FontProvider
      * @param postScriptName PostScript font name
      */
     public Type1Font getType1Font(String postScriptName);
+
+    /**
+     * Returns a string containing debugging information. This will be written to the log
if no
+     * suitable fonts are found and no fallback fonts are available. May be null.
+     */
+    public String toDebugString();
 }



Mime
View raw message