Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
2.5
-
None
-
macOS Mojave
java version "1.8.0_192-ea"
Java(TM) SE Runtime Environment (build 1.8.0_192-ea-b04)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b04, mixed mode)
Description
fop-core/src/main/java/org/apache/fop/pdf/PDFToUnicodeCMap.java writeBFCharEntries runs through the codepoint entries in sections of 100 at a time. It looks like there's an edge case here where the last entry in the section is a surrogate pair.
Here's my steps to reproduce from the latest trunk:
java -cp fop/target/fop-2.5.0-SNAPSHOT.jar:fop/lib/commons-logging-1.0.4.jar:fop/lib/commons-io-1.3.1.jar:fop/lib/xmlgraphics-commons-svn-trunk.jar org.apache.fop.fonts.apps.TTFReader TwitterColorEmoji-SVGinOT.ttf twe.xml
java -cp fop/target/fop-2.5.0-SNAPSHOT.jar:fop/lib/commons-logging-1.0.4.jar:fop/lib/commons-io-1.3.1.jar:fop/lib/xmlgraphics-commons-svn-trunk.jar:fop/lib/batik-all-1.11.0-SNAPSHOT.jar org.apache.fop.cli.Main -c twe_userconfig.xml -xsl twe_template.fo -xml fail.xml -pdf fail.pdf
Here's the temporary way I resolved it for my own build:
index ee773dcec..37c21803e 100644
— a/fop-core/src/main/java/org/apache/fop/pdf/PDFToUnicodeCMap.java
+++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFToUnicodeCMap.java
@@ -128,6 +128,18 @@ public class PDFToUnicodeCMap extends PDFCMap {
while (partOfRange(charArray, charIndex))
/*
- If this entry is going to overflow the entriesThisSection
- array, then don't use it. This happens if there are
- non-pair entries in the table mixed with pair entries.
*/
if (Character.codePointAt(charArray, charIndex) > 0xFFFF
&& i+1 >= entriesThisSection) { entriesThisSection--; break; }
writer.write("<" + padCharIndex(charIndex) + "> ");
if (Character.codePointAt(charArray, charIndex) > 0xFFFF) {