]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2792: Add boundingbox for OTF
authorSimon Steiner <ssteiner@apache.org>
Wed, 9 May 2018 10:41:40 +0000 (10:41 +0000)
committerSimon Steiner <ssteiner@apache.org>
Wed, 9 May 2018 10:41:40 +0000 (10:41 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1831245 13f79535-47bb-0310-9956-ffa450edef68

fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java
fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java

index 2f52fa7916a63d99ad74b7b9ffe912a2221a9f5d..683fd51b15392cde42742ffed3f704575f2962a8 100644 (file)
@@ -20,6 +20,7 @@
 package org.apache.fop.fonts.truetype;
 
 import java.io.IOException;
+import java.util.List;
 
 import org.apache.fontbox.cff.CFFDataInput;
 import org.apache.fontbox.cff.CFFFont;
@@ -50,6 +51,17 @@ public class OTFFile extends OpenFont {
 
     @Override
     protected void updateBBoxAndOffset() throws IOException {
+        Object bbox = fileFont.getTopDict().get("FontBBox");
+        if (bbox != null) {
+            List bboxList = (List) bbox;
+            int[] bboxInt = new int[4];
+            for (int i = 0; i < bboxInt.length; i++) {
+                bboxInt[i] = (Integer) bboxList.get(i);
+            }
+            for (OFMtxEntry o : mtxTab) {
+                o.setBoundingBox(bboxInt);
+            }
+        }
     }
 
     private static class Mapping {
index 39b6fd50f1b24ad317f2c8fbf77c9599990f59b3..1f64f1baa17f379510be17ff8b09743f4dab9f05 100644 (file)
@@ -19,6 +19,7 @@
 
 package org.apache.fop.fonts.truetype;
 
+import java.awt.Rectangle;
 import java.io.FileInputStream;
 import java.io.InputStream;
 
@@ -82,4 +83,9 @@ public class OTFFileTestCase {
             assertEquals(carolynaWidths[i], alexBrush.getWidths()[gids[i]]);
         }
     }
+
+    @Test
+    public void testBoundingBoxes() {
+        assertEquals(sourceSansProBold.getBoundingBoxes()[0], new Rectangle(-231, -384, 1454, 1358));
+    }
 }