From 33ae6deb2efce2a7892af13d5a2527b7d5f6813f Mon Sep 17 00:00:00 2001 From: Simon Steiner Date: Wed, 8 Mar 2017 13:58:08 +0000 Subject: [PATCH] FOP-2697: Adobe Reader error with Adobe Kozuka Mincho font git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1785969 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/fonts/truetype/OTFSubSetFile.java | 2 +- .../fonts/truetype/OTFSubSetFileTestCase.java | 20 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 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 5ee54eaa8..bb5c48910 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 @@ -172,7 +172,7 @@ public class OTFSubSetFile extends OTFFile { writeBytes(cffReader.getHeader()); //Name Index - writeIndex(Arrays.asList(embeddedName.getBytes())); + writeIndex(Arrays.asList(embedFontName.getBytes())); //Keep offset of the topDICT so it can be updated once all data has been written int topDictOffset = currentPos; 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 d87d19be5..e653f7f9c 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 @@ -37,6 +37,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import org.apache.fontbox.cff.CFFFont; +import org.apache.fontbox.cff.CFFParser; import org.apache.fop.fonts.cff.CFFDataReader; import org.apache.fop.fonts.cff.CFFDataReader.CFFIndexData; @@ -435,8 +436,8 @@ public class OTFSubSetFileTestCase extends OTFFileTestCase { @Test public void testFDSelect() throws IOException { - Assert.assertEquals(getSubset(1).length, 39); - Assert.assertEquals(getSubset(2).length, 46); + Assert.assertEquals(getSubset(1).length, 41); + Assert.assertEquals(getSubset(2).length, 48); } private byte[] getSubset(final int opLen) throws IOException { @@ -468,4 +469,19 @@ public class OTFSubSetFileTestCase extends OTFFileTestCase { otfSubSetFile.readFont(reader, "StandardOpenType", header, new HashMap()); return otfSubSetFile.getFontSubset(); } + + @Test + public void testOffsets() throws IOException { + Map glyphs = new HashMap(); + for (int i = 0; i < 256; i++) { + glyphs.put(i, i); + } + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 2048; i++) { + sb.append("SourceSansProBold"); + } + OTFSubSetFile otfSubSetFile = new OTFSubSetFile(); + otfSubSetFile.readFont(sourceSansReader, sb.toString(), null, glyphs); + new CFFParser().parse(otfSubSetFile.getFontSubset()); + } } -- 2.39.5