Browse Source

FOP-2902: Ignore TTF reserved index range

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1872774 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-2_5
Simon Steiner 4 years ago
parent
commit
da0f281740

+ 1
- 1
fop-core/src/main/java/org/apache/fop/fonts/truetype/OpenFont.java View File

@@ -1406,7 +1406,7 @@ public abstract class OpenFont {
for (int i = 0; i < l; i++) {
mtxTab[i].setIndex(fontFile.readTTFUShort());

if (mtxTab[i].getIndex() > numGlyphStrings) {
if (mtxTab[i].getIndex() > numGlyphStrings && mtxTab[i].getIndex() <= 32767) {
numGlyphStrings = mtxTab[i].getIndex();
}


+ 23
- 0
fop-core/src/test/java/org/apache/fop/fonts/truetype/TTFFileTestCase.java View File

@@ -19,9 +19,13 @@

package org.apache.fop.fonts.truetype;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@@ -572,4 +576,23 @@ public class TTFFileTestCase {
assertEquals(dejavuTTFFile.getBBox(1)[0], 49);
assertEquals(dejavuTTFFile.getBBox(2330).length, 4);
}

@Test
public void testReservedIndex() throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
dos.write(0);
dos.write(2);
for (int i = 0; i < 31; i++) {
dos.write(0);
}
dos.write(1); //number of glyphs
dos.writeShort(32768); //index value
TTFFile ttfFile = new TTFFile();
ttfFile.dirTabs = new HashMap<OFTableName, OFDirTabEntry>();
ttfFile.fontFile = new FontFileReader(new ByteArrayInputStream(bos.toByteArray()));
ttfFile.mtxTab = new OFMtxEntry[1];
ttfFile.mtxTab[0] = new OFMtxEntry();
ttfFile.readPostScript();
}
}

Loading…
Cancel
Save