aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2017-10-12 14:43:48 +0000
committerSimon Steiner <ssteiner@apache.org>2017-10-12 14:43:48 +0000
commit7645c8c63a6e1d9fa19ad51bf896038300d681ce (patch)
tree10e475de77af9274f19120067dbe92ba2b651773
parentd81e5851f7c083b4bd86867dee19bc4f19c5610e (diff)
downloadxmlgraphics-fop-7645c8c63a6e1d9fa19ad51bf896038300d681ce.tar.gz
xmlgraphics-fop-7645c8c63a6e1d9fa19ad51bf896038300d681ce.zip
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
-rw-r--r--fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java4
-rw-r--r--fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java9
2 files changed, 7 insertions, 6 deletions
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 {