Author: lehmi
Date: Sun Mar 27 11:53:27 2011
New Revision: 1085916

URL: http://svn.apache.org/viewvc?rev=1085916&view=rev
Log:
PDFBOX-959: create the awt font only if needed

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

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java?rev=1085916&r1=1085915&r2=1085916&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
 Sun Mar 27 11:53:27 2011
@@ -160,7 +160,6 @@ public class PDType1Font extends PDSimpl
                 try 
                 {
                     type1CFont = new PDType1CFont( super.font );
-                    awtFont = type1CFont.getawtFont();
                 }
                 catch (IOException exception) 
                 {
@@ -212,48 +211,49 @@ public class PDType1Font extends PDSimpl
     {
         if( awtFont == null )
         {
-            String baseFont = getBaseFont();
-            PDFontDescriptor fd = getFontDescriptor();
-            if (fd != null && fd instanceof PDFontDescriptorDictionary)
+            if (type1CFont != null)
             {
-                PDFontDescriptorDictionary fdDictionary = 
(PDFontDescriptorDictionary)fd;
-                if( fdDictionary.getFontFile() != null )
+                awtFont = type1CFont.getawtFont();
+            }
+            else
+            {
+                String baseFont = getBaseFont();
+                PDFontDescriptor fd = getFontDescriptor();
+                if (fd != null && fd instanceof PDFontDescriptorDictionary)
                 {
-                    try 
+                    PDFontDescriptorDictionary fdDictionary = 
(PDFontDescriptorDictionary)fd;
+                    if( fdDictionary.getFontFile() != null )
                     {
-                        // create a type1 font with the embedded data
-                        awtFont = Font.createFont( Font.TYPE1_FONT, 
fdDictionary.getFontFile().createInputStream() );
-                    } 
-                    catch (FontFormatException e) 
+                        try 
+                        {
+                            // create a type1 font with the embedded data
+                            awtFont = Font.createFont( Font.TYPE1_FONT, 
fdDictionary.getFontFile().createInputStream() );
+                        } 
+                        catch (FontFormatException e) 
+                        {
+                            log.info("Can't read the embedded type1 font " + 
fd.getFontName() );
+                        }
+                    }
+                    if (awtFont == null)
                     {
-                        log.info("Can't read the embedded type1 font " + 
fd.getFontName() );
+                        // check if the font is part of our environment
+                        awtFont = FontManager.getAwtFont(fd.getFontName());
+                        if (awtFont == null)
+                        {
+                            log.info("Can't find the specified font " + 
fd.getFontName() );
+                        }
                     }
                 }
-                else if( fdDictionary.getFontFile3() != null)
-                {
-                    type1CFont = new PDType1CFont( super.font );
-                    awtFont = type1CFont.getawtFont();
-                }
-                
-                if (awtFont == null)
+                else
                 {
                     // check if the font is part of our environment
-                    awtFont = FontManager.getAwtFont(fd.getFontName());
-                    if (awtFont == null)
+                    awtFont = FontManager.getAwtFont(baseFont);
+                    if (awtFont == null) 
                     {
-                        log.info("Can't find the specified font " + 
fd.getFontName() );
+                        log.info("Can't find the specified basefont " + 
baseFont );
                     }
                 }
             }
-            else
-            {
-                // check if the font is part of our environment
-                awtFont = FontManager.getAwtFont(baseFont);
-                if (awtFont == null) 
-                {
-                    log.info("Can't find the specified basefont " + baseFont );
-                }
-            }
             if (awtFont == null)
             {
                 // we can't find anything, so we have to use the standard font


Reply via email to