Author: ssteiner
Date: Wed May  9 10:41:40 2018
New Revision: 1831245

URL: http://svn.apache.org/viewvc?rev=1831245&view=rev
Log:
FOP-2792: Add boundingbox for OTF

Modified:
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java
    
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java?rev=1831245&r1=1831244&r2=1831245&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java
 Wed May  9 10:41:40 2018
@@ -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 {

Modified: 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java?rev=1831245&r1=1831244&r2=1831245&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java
 Wed May  9 10:41:40 2018
@@ -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));
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-h...@xmlgraphics.apache.org

Reply via email to