Author: danielwilson
Date: Wed Feb 10 23:52:32 2010
New Revision: 908762

URL: http://svn.apache.org/viewvc?rev=908762&view=rev
Log:
Use font substitution to avoid throwing an exception and crashing.

Modified:
    pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java

Modified: 
pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java?rev=908762&r1=908761&r2=908762&view=diff
==============================================================================
--- 
pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java 
(original)
+++ 
pdfbox/trunk/src/main/java/org/apache/pdfbox/pdmodel/font/PDFontFactory.java 
Wed Feb 10 23:52:32 2010
@@ -22,6 +22,8 @@
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSStream;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * This will create the correct type of font based on information in the 
dictionary.
@@ -39,6 +41,11 @@
     }
 
     /**
+     * Logger instance.
+     */
+    private static final Log log = LogFactory.getLog(PDFontFactory.class);
+    
+    /**
      * This will create the correct font based on information in the 
dictionary.
      *
      * @param dic The populated dictionary.
@@ -143,7 +150,9 @@
         }
         else
         {
-            throw new IOException( "Unknown font subtype=" + subType );
+            log.warn("Substituting TrueType for unknown font subtype=" + 
dic.getDictionaryObject( COSName.SUBTYPE ).toString());
+            //throw new IOException( "Unknown font subtype=" + subType );
+            retval = new PDTrueTypeFont( dic );
         }
         return retval;
     }


Reply via email to