summaryrefslogtreecommitdiffstats
path: root/fop-core
diff options
context:
space:
mode:
Diffstat (limited to 'fop-core')
-rw-r--r--fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java8
-rw-r--r--fop-core/src/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java6
2 files changed, 11 insertions, 3 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java
index 95e2e4cc0..aa6739f15 100644
--- a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java
+++ b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java
@@ -1040,10 +1040,12 @@ public abstract class OpenFont {
* @return int[] Array defining bounding box.
*/
public int[] getBBox(int glyphIndex) {
- int[] bboxInTTFUnits = mtxTab[glyphIndex].getBoundingBox();
int[] bbox = new int[4];
- for (int i = 0; i < 4; i++) {
- bbox[i] = convertTTFUnit2PDFUnit(bboxInTTFUnits[i]);
+ if (glyphIndex < mtxTab.length) {
+ int[] bboxInTTFUnits = mtxTab[glyphIndex].getBoundingBox();
+ for (int i = 0; i < 4; i++) {
+ bbox[i] = convertTTFUnit2PDFUnit(bboxInTTFUnits[i]);
+ }
}
return bbox;
}
diff --git a/fop-core/src/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java b/fop-core/src/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java
index 06fef70cc..a66c6d49e 100644
--- a/fop-core/src/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java
+++ b/fop-core/src/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java
@@ -454,4 +454,10 @@ public class TTFFileTestCase {
public void testReadFont() {
// I'm pretty sure we've tested this with all the other tests
}
+
+ @Test
+ public void testBBox() {
+ assertEquals(dejavuTTFFile.getBBox(1)[0], 49);
+ assertEquals(dejavuTTFFile.getBBox(2330).length, 4);
+ }
}