pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1728342 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font: FontMapperImpl.java PDCIDFontType0.java PDCIDFontType2.java PDTrueTypeFont.java PDType0Font.java PDType1CFont.java PDType1Font.java PDType3Font.java
Date Wed, 03 Feb 2016 16:54:24 GMT
Author: tilman
Date: Wed Feb  3 16:54:24 2016
New Revision: 1728342

URL: http://svn.apache.org/viewvc?rev=1728342&view=rev
Log:
PDFBOX-3224: cache found BBox as suggested by Tom Callahan

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType0.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1Font.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java?rev=1728342&r1=1728341&r2=1728342&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java Wed
Feb  3 16:54:24 2016
@@ -656,9 +656,12 @@ final class FontMapperImpl implements Fo
             {
                 return true;
             }
-            else return cidSystemInfo.getOrdering().equals("Korea1") &&
+            else
+            {
+                return cidSystemInfo.getOrdering().equals("Korea1") &&
                         (codePageRange & KOREAN_WANSUNG) == KOREAN_WANSUNG ||
                         (codePageRange & KOREAN_JOHAB) == KOREAN_JOHAB;
+            }
         }
     }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType0.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType0.java?rev=1728342&r1=1728341&r2=1728342&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType0.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType0.java Wed
Feb  3 16:54:24 2016
@@ -61,6 +61,7 @@ public class PDCIDFontType0 extends PDCI
     private Float avgWidth = null;
     private Matrix fontMatrix;
     private final AffineTransform fontMatrixTransform;
+    private BoundingBox fontBBox;
 
     /**
      * Constructor.
@@ -202,6 +203,15 @@ public class PDCIDFontType0 extends PDCI
     @Override
     public BoundingBox getBoundingBox()
     {
+        if (fontBBox == null)
+        {
+            fontBBox = generateBoundingBox();
+        }
+        return fontBBox;
+    }
+
+    private BoundingBox generateBoundingBox()
+    {
         if (getFontDescriptor() != null) {
             PDRectangle bbox = getFontDescriptor().getFontBoundingBox();
             if (bbox.getLowerLeftX() != 0 || bbox.getLowerLeftY() != 0 ||

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java?rev=1728342&r1=1728341&r2=1728342&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java Wed
Feb  3 16:54:24 2016
@@ -56,6 +56,7 @@ public class PDCIDFontType2 extends PDCI
     private final boolean isDamaged;
     private final CmapSubtable cmap; // may be null
     private Matrix fontMatrix;
+    private BoundingBox fontBBox;
 
     /**
      * Constructor.
@@ -197,6 +198,15 @@ public class PDCIDFontType2 extends PDCI
     @Override
     public BoundingBox getBoundingBox() throws IOException
     {
+        if (fontBBox == null)
+        {
+            fontBBox = generateBoundingBox();
+        }
+        return fontBBox;
+    }
+
+    private BoundingBox generateBoundingBox() throws IOException
+    {
         if (getFontDescriptor() != null) {
             PDRectangle bbox = getFontDescriptor().getFontBoundingBox();
             if (bbox.getLowerLeftX() != 0 || bbox.getLowerLeftY() != 0 ||

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java?rev=1728342&r1=1728341&r2=1728342&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFont.java Wed
Feb  3 16:54:24 2016
@@ -152,6 +152,7 @@ public class PDTrueTypeFont extends PDSi
     private final TrueTypeFont ttf;
     private final boolean isEmbedded;
     private final boolean isDamaged;
+    private BoundingBox fontBBox;
 
     /**
      * Creates a new TrueType font from a Font dictionary.
@@ -301,6 +302,15 @@ public class PDTrueTypeFont extends PDSi
     @Override
     public BoundingBox getBoundingBox() throws IOException
     {
+        if (fontBBox == null)
+        {
+            fontBBox = generateBoundingBox();
+        }
+        return fontBBox;
+    }
+
+    private BoundingBox generateBoundingBox() throws IOException
+    {
         if (getFontDescriptor() != null) {
             PDRectangle bbox = getFontDescriptor().getFontBoundingBox();
             return new BoundingBox(bbox.getLowerLeftX(), bbox.getLowerLeftY(),

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java?rev=1728342&r1=1728341&r2=1728342&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType0Font.java Wed
Feb  3 16:54:24 2016
@@ -445,6 +445,7 @@ public class PDType0Font extends PDFont
     @Override
     public BoundingBox getBoundingBox() throws IOException
     {
+        // Will be cached by underlying font
         return descendantFont.getBoundingBox();
     }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java?rev=1728342&r1=1728341&r2=1728342&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType1CFont.java Wed
Feb  3 16:54:24 2016
@@ -64,6 +64,7 @@ public class PDType1CFont extends PDSimp
     private final FontBoxFont genericFont; // embedded or system font for rendering
     private final boolean isEmbedded;
     private final boolean isDamaged;
+    private BoundingBox fontBBox;
 
     /**
      * Constructor.
@@ -185,6 +186,15 @@ public class PDType1CFont extends PDSimp
     @Override
     public BoundingBox getBoundingBox() throws IOException
     {
+        if (fontBBox == null)
+        {
+            fontBBox = generateBoundingBox();
+        }
+        return fontBBox;
+    }
+
+    private BoundingBox generateBoundingBox() throws IOException
+    {
         if (getFontDescriptor() != null) {
             PDRectangle bbox = getFontDescriptor().getFontBoundingBox();
             if (bbox.getLowerLeftX() != 0 || bbox.getLowerLeftY() != 0 ||

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=1728342&r1=1728341&r2=1728342&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 Wed
Feb  3 16:54:24 2016
@@ -94,6 +94,7 @@ public class PDType1Font extends PDSimpl
     private final boolean isDamaged;
     private Matrix fontMatrix;
     private final AffineTransform fontMatrixTransform;
+    private BoundingBox fontBBox;
 
     /**
      * Creates a Type 1 standard 14 font for embedding.
@@ -447,6 +448,15 @@ public class PDType1Font extends PDSimpl
     @Override
     public BoundingBox getBoundingBox() throws IOException
     {
+        if (fontBBox == null)
+        {
+            fontBBox = generateBoundingBox();
+        }
+        return fontBBox;
+    }
+
+    private BoundingBox generateBoundingBox() throws IOException
+    {
         if (getFontDescriptor() != null) {
             PDRectangle bbox = getFontDescriptor().getFontBoundingBox();
             if (bbox.getLowerLeftX() != 0 || bbox.getLowerLeftY() != 0 ||

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java?rev=1728342&r1=1728341&r2=1728342&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDType3Font.java Wed
Feb  3 16:54:24 2016
@@ -261,10 +261,15 @@ public class PDType3Font extends PDSimpl
     @Override
     public BoundingBox getBoundingBox()
     {
-        if (fontBBox != null)
+        if (fontBBox == null)
         {
-            return fontBBox;
+            fontBBox = generateBoundingBox();
         }
+        return fontBBox;
+    }
+
+    private BoundingBox generateBoundingBox()
+    {
         PDRectangle rect = getFontBBox();
         if (rect.getLowerLeftX() == 0 && rect.getLowerLeftY() == 0
                 && rect.getUpperRightX() == 0 && rect.getUpperRightY() ==
0)
@@ -296,9 +301,8 @@ public class PDType3Font extends PDSimpl
                 }
             }
         }
-        fontBBox = new BoundingBox(rect.getLowerLeftX(), rect.getLowerLeftY(),
+        return new BoundingBox(rect.getLowerLeftX(), rect.getLowerLeftY(),
                 rect.getUpperRightX(), rect.getUpperRightY());
-        return fontBBox;
     }
 
     /**



Mime
View raw message