aboutsummaryrefslogtreecommitdiffstats
path: root/fop-core
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2023-04-26 13:59:23 +0100
committerSimon Steiner <ssteiner@apache.org>2023-04-26 13:59:23 +0100
commit387218dde1dcc8b7bf68065ae5b78411c45a89d6 (patch)
tree63664887dea19681f4c07f4c1dbeb66e013efb91 /fop-core
parent6696559fc657aa3d83b868c337ced59e6a44ca7b (diff)
downloadxmlgraphics-fop-387218dde1dcc8b7bf68065ae5b78411c45a89d6.tar.gz
xmlgraphics-fop-387218dde1dcc8b7bf68065ae5b78411c45a89d6.zip
FOP-3130: Correct font differences table for Chrome
Diffstat (limited to 'fop-core')
-rw-r--r--fop-core/src/main/java/org/apache/fop/pdf/PDFFactory.java2
-rw-r--r--fop-core/src/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java34
2 files changed, 35 insertions, 1 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFFactory.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFFactory.java
index f0456a53f..0b69a8f64 100644
--- a/fop-core/src/main/java/org/apache/fop/pdf/PDFFactory.java
+++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFFactory.java
@@ -1092,7 +1092,7 @@ public class PDFFactory {
if (charNameMap.length < len) {
len = charNameMap.length;
}
- int last = 0;
+ int last = Integer.MIN_VALUE;
for (int i = 0; i < len; i++) {
if (intmap[i] - 1 != last) {
differences.add(intmap[i]);
diff --git a/fop-core/src/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java b/fop-core/src/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java
index d6d7c50c1..14745cdee 100644
--- a/fop-core/src/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java
+++ b/fop-core/src/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java
@@ -46,6 +46,7 @@ import org.apache.fop.fonts.FontType;
import org.apache.fop.fonts.FontUris;
import org.apache.fop.fonts.MultiByteFont;
import org.apache.fop.fonts.NamedCharacter;
+import org.apache.fop.fonts.SingleByteEncoding;
import org.apache.fop.fonts.SingleByteFont;
import org.apache.fop.fonts.truetype.OFFontLoader;
@@ -111,6 +112,35 @@ public class PDFFactoryTestCase {
}
@Test
+ public void testDifferencesStartValue() throws IOException {
+ PDFDocument doc = new PDFDocument("");
+ PDFFactory pdfFactory = new PDFFactory(doc);
+ TestSingleByteFont sb = new TestSingleByteFont(null);
+ sb.setFlags(0);
+ sb.setMapping(new SingleByteEncoding() {
+ public String getName() {
+ return "FOPPDFEncoding";
+ }
+
+ public char mapChar(char c) {
+ return 0;
+ }
+
+ public String[] getCharNameMap() {
+ return new String[]{"a"};
+ }
+
+ public char[] getUnicodeCharMap() {
+ return new char[]{1};
+ }
+ });
+ pdfFactory.makeFont("a", "a", "WinAnsiEncoding", sb, sb);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ doc.outputTrailer(bos);
+ assertTrue(bos.toString().contains("/Differences [1 /a]"));
+ }
+
+ @Test
public void testMakeTrueTypeFont() throws IOException {
PDFDocument doc = new PDFDocument("");
PDFFactory pdfFactory = new PDFFactory(doc);
@@ -135,6 +165,10 @@ public class PDFFactoryTestCase {
File f = new File("test/resources/fonts/type1/a010013l.pfb");
return new FileInputStream(f);
}
+
+ public void setMapping(SingleByteEncoding mapping) {
+ this.mapping = mapping;
+ }
}
@Test