Author: ssteiner
Date: Thu Feb  9 15:56:53 2017
New Revision: 1782353

URL: http://svn.apache.org/viewvc?rev=1782353&view=rev
Log:
FOP-2598: ArrayIndexOutOfBoundException while loading TTF font OCRB

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

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java?rev=1782353&r1=1782352&r2=1782353&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java
 Thu Feb  9 15:56:53 2017
@@ -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;
     }

Modified: 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java?rev=1782353&r1=1782352&r2=1782353&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java
 Thu Feb  9 15:56:53 2017
@@ -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);
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to