You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ja...@apache.org on 2014/07/01 04:02:21 UTC

svn commit: r1606963 - /pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/util/FontManager.java

Author: jahewson
Date: Tue Jul  1 02:02:21 2014
New Revision: 1606963

URL: http://svn.apache.org/r1606963
Log:
PDFBOX-2169: lazy load the standard TTF font

Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/util/FontManager.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/util/FontManager.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/util/FontManager.java?rev=1606963&r1=1606962&r2=1606963&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/util/FontManager.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/util/FontManager.java Tue Jul  1 02:02:21 2014
@@ -53,39 +53,6 @@ public class FontManager
     // fallback font
     private static TrueTypeFont standardFont;
 
-    static
-    {
-        try
-        {
-            // todo: make this configurable
-
-            // Windows
-            standardFont = findTTFont("Arial");
-
-            if (standardFont == null)
-            {
-                // OS X
-                standardFont = findTTFont("Helvetica");
-            }
-
-            if (standardFont == null)
-            {
-                // Linux
-                standardFont = findTTFont("Liberation Sans");
-            }
-
-            if (standardFont == null)
-            {
-                throw new IOException("Could not load TTF fallback font");
-            }
-        }
-        catch (IOException e)
-        {
-            LOG.error(e);
-            throw new RuntimeException(e);
-        }
-    }
-
     private FontManager()
     {
     }
@@ -379,8 +346,32 @@ public class FontManager
      *
      * @return standard font
      */
-    public static TrueTypeFont getStandardFont()
+    public static TrueTypeFont getStandardFont() throws IOException
     {
+        if (standardFont == null)
+        {
+            // todo: make this configurable
+
+            // Windows
+            standardFont = findTTFont("Arial");
+
+            if (standardFont == null)
+            {
+                // OS X
+                standardFont = findTTFont("Helvetica");
+            }
+
+            if (standardFont == null)
+            {
+                // Linux
+                standardFont = findTTFont("Liberation Sans");
+            }
+
+            if (standardFont == null)
+            {
+                throw new IOException("Could not load TTF fallback font");
+            }
+        }
         return standardFont;
     }
 }