svn commit: r1782353 - in /xmlgraphics/fop/trunk/fop-core/src: main/java/org/apache/fop/fonts/truetype/OpenFont.java test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java

[email protected]
Newsgroups gmane.text.xml.fop.cvs
Message-ID <[email protected]>
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);
+    }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.