From: Simon Steiner Date: Thu, 12 Oct 2017 14:43:48 +0000 (+0000) Subject: FOP-2751: OTF subset: correct charstring offset size X-Git-Tag: fop-2_3~25 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7645c8c63a6e1d9fa19ad51bf896038300d681ce;p=xmlgraphics-fop.git FOP-2751: OTF subset: correct charstring offset size git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1811970 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java index fd3a9988e..7884fff85 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java @@ -282,8 +282,8 @@ public class OTFSubSetFile extends OTFSubSetWriter { DICTEntry entry = dictEntry.getValue(); //If the value is an SID, update the reference but keep the size the same entry.setOffset(entry.getOffset() + offsetExtra); - if (dictKey.equals("CharStrings") && entry.getOperandLength() == 3) { - byte[] extra = new byte[2]; + if (dictKey.equals("CharStrings") && entry.getOperandLength() < 5) { + byte[] extra = new byte[5 - entry.getOperandLength()]; offsetExtra += extra.length; dict.write(extra); dict.write(entry.getByteData()); diff --git a/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java b/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java index c872c731e..fef8ce114 100644 --- a/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java @@ -446,8 +446,8 @@ public class OTFSubSetFileTestCase extends OTFFileTestCase { @Test public void testFDSelect() throws IOException { - Assert.assertEquals(getSubset(1).length, 42); - Assert.assertEquals(getSubset(2).length, 49); + Assert.assertEquals(getSubset(1).length, 46); + Assert.assertEquals(getSubset(2).length, 45); } private byte[] getSubset(final int opLen) throws IOException { @@ -583,9 +583,10 @@ public class OTFSubSetFileTestCase extends OTFFileTestCase { public void testOrderOfEntries() throws IOException { OTFSubSetFileEntryOrder otfSubSetFile = getFont(3, 2); assertTrue(otfSubSetFile.offsets.fdArray < otfSubSetFile.offsets.charString); - + assertEquals(otfSubSetFile.cffReader.getTopDictEntries().get("CharStrings").getOperandLength(), 5); otfSubSetFile = getFont(2, 3); - assertTrue(otfSubSetFile.offsets.fdArray > otfSubSetFile.offsets.charString); + assertTrue(otfSubSetFile.offsets.fdArray < otfSubSetFile.offsets.charString); + assertEquals(otfSubSetFile.cffReader.getTopDictEntries().get("CharStrings").getOperandLength(), 5); } private OTFSubSetFileEntryOrder getFont(int csLen, int fdLen) throws IOException {