diff options
author | Simon Steiner <ssteiner@apache.org> | 2018-05-09 10:41:40 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2018-05-09 10:41:40 +0000 |
commit | f24243e01f0e8bc0e1aec2c8c263c8215561e099 (patch) | |
tree | 784f3246d3658b749229ebc6caa3dc9c9890a687 | |
parent | 330656e9e1cda3ab8a1f3f5a7768f766029bf700 (diff) | |
download | xmlgraphics-fop-f24243e01f0e8bc0e1aec2c8c263c8215561e099.tar.gz xmlgraphics-fop-f24243e01f0e8bc0e1aec2c8c263c8215561e099.zip |
FOP-2792: Add boundingbox for OTF
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1831245 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java | 12 | ||||
-rw-r--r-- | fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java | 6 |
2 files changed, 18 insertions, 0 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java index 2f52fa791..683fd51b1 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java @@ -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 { diff --git a/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java b/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java index 39b6fd50f..1f64f1baa 100644 --- a/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFFileTestCase.java @@ -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)); + } } |