aboutsummaryrefslogtreecommitdiffstats
path: root/fop-core/src/test
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2022-09-27 07:04:02 +0000
committerSimon Steiner <ssteiner@apache.org>2022-09-27 07:04:02 +0000
commit575503a3fe9d7ad808a7f14091555e3cf13abdd3 (patch)
tree20a00c983fc78172dff2578c3ae2fa2e680e76ca /fop-core/src/test
parent06812639c573b6973553d188f78e1ac57ccfa864 (diff)
downloadxmlgraphics-fop-575503a3fe9d7ad808a7f14091555e3cf13abdd3.tar.gz
xmlgraphics-fop-575503a3fe9d7ad808a7f14091555e3cf13abdd3.zip
FOP-3093: Stop reading ttf if we hit last offset
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1904293 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core/src/test')
-rw-r--r--fop-core/src/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java22
1 files changed, 22 insertions, 0 deletions
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 c2d84482f..061353abb 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
@@ -29,6 +29,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -595,4 +596,25 @@ public class TTFFileTestCase {
ttfFile.mtxTab[0] = new OFMtxEntry();
ttfFile.readPostScript();
}
+
+ @Test
+ public void testStopReadAtLastOffset() throws IOException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(bos);
+ dos.writeShort(0);
+ dos.writeShort(4);
+ dos.writeShort(4);
+ dos.writeLong(0);
+ TTFFile ttfFile = new TTFFile();
+ ttfFile.dirTabs = new HashMap<>();
+ ttfFile.dirTabs.put(OFTableName.LOCA, new OFDirTabEntry());
+ ttfFile.dirTabs.put(OFTableName.GLYF, new OFDirTabEntry());
+ ttfFile.fontFile = new FontFileReader(new ByteArrayInputStream(bos.toByteArray()));
+ ttfFile.numberOfGlyphs = 2;
+ ttfFile.mtxTab = new OFMtxEntry[2];
+ ttfFile.mtxTab[0] = new OFMtxEntry();
+ ttfFile.mtxTab[1] = new OFMtxEntry();
+ ttfFile.updateBBoxAndOffset();
+ Assert.assertEquals(ttfFile.mtxTab[0].getBoundingBox()[0], 4);
+ }
}