summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2017-02-09 15:56:53 +0000
committerSimon Steiner <ssteiner@apache.org>2017-02-09 15:56:53 +0000
commitcf0660bbaecd7d7a4fb6adc3cb66cb564305a99d (patch)
treed5dc4a47bf71f60b3b6aa6285b794ece143dad3f
parent5c8a6c2f417cb2cbc0fcfeebcbae7afc95d6c92b (diff)
downloadxmlgraphics-fop-cf0660bbaecd7d7a4fb6adc3cb66cb564305a99d.tar.gz
xmlgraphics-fop-cf0660bbaecd7d7a4fb6adc3cb66cb564305a99d.zip
FOP-2598: ArrayIndexOutOfBoundException while loading TTF font OCRB
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1782353 13f79535-47bb-0310-9956-ffa450edef68
-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);
+ }
}