xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sstei...@apache.org
Subject svn commit: r1823552 - in /xmlgraphics/fop/trunk/fop-core/src: main/java/org/apache/fop/pdf/PDFFactory.java test/java/org/apache/fop/pdf/PDFFactoryTestCase.java
Date Thu, 08 Feb 2018 12:26:33 GMT
Author: ssteiner
Date: Thu Feb  8 12:26:33 2018
New Revision: 1823552

URL: http://svn.apache.org/viewvc?rev=1823552&view=rev
Log:
FOP-2770: Merge fonts not handling Truetype MacRomanEncoding

Modified:
    xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/pdf/PDFFactory.java
    xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java

Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/pdf/PDFFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/pdf/PDFFactory.java?rev=1823552&r1=1823551&r2=1823552&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/pdf/PDFFactory.java (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/pdf/PDFFactory.java Thu Feb
 8 12:26:33 2018
@@ -1061,7 +1061,7 @@ public class PDFFactory {
                     //believed.
                 } else if (mapping.getName().equals("FOPPDFEncoding")) {
                     if (fonttype == FontType.TRUETYPE) {
-                        font.setEncoding("WinAnsiEncoding");
+                        font.setEncoding(encoding);
                     } else {
                         String[] charNameMap = mapping.getCharNameMap();
                         char[] intmap = mapping.getUnicodeCharMap();

Modified: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java?rev=1823552&r1=1823551&r2=1823552&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java
(original)
+++ xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/pdf/PDFFactoryTestCase.java
Thu Feb  8 12:26:33 2018
@@ -19,9 +19,12 @@
 
 package org.apache.fop.pdf;
 
+import java.awt.Rectangle;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URI;
 
 import org.junit.Test;
@@ -34,10 +37,14 @@ import org.apache.fop.apps.io.InternalRe
 import org.apache.fop.apps.io.ResourceResolverFactory;
 import org.apache.fop.fonts.CIDSet;
 import org.apache.fop.fonts.CIDSubset;
+import org.apache.fop.fonts.CodePointMapping;
 import org.apache.fop.fonts.CustomFont;
 import org.apache.fop.fonts.EmbeddingMode;
+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.SingleByteFont;
 import org.apache.fop.fonts.truetype.OFFontLoader;
 
 /**
@@ -82,6 +89,53 @@ public class PDFFactoryTestCase {
     }
 
     @Test
+    public void testMakeFont() throws IOException {
+        PDFDocument doc = new PDFDocument("");
+        PDFFactory pdfFactory = new PDFFactory(doc);
+        SingleByteFont sb = new TestSingleByteFont(null);
+        sb.setFontName("test");
+        sb.setWidth(0, 0);
+        sb.setFlags(0);
+        sb.setEmbedResourceName("");
+        sb.mapChar('a');
+        sb.addUnencodedCharacter(new NamedCharacter("xyz", String.valueOf((char) 0x2202)),
0, new Rectangle());
+        sb.mapChar((char) 0x2202);
+        sb.setEncoding(new CodePointMapping("FOPPDFEncoding", new int[0]));
+        PDFFont font = pdfFactory.makeFont("a", "a", "WinAnsiEncoding", sb, sb);
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        font.output(bos);
+        assertTrue(bos.toString().contains("/BaseFont /EAAAAA+a"));
+        assertEquals(sb.getAdditionalEncodingCount(), 1);
+    }
+
+    @Test
+    public void testMakeTrueTypeFont() throws IOException {
+        PDFDocument doc = new PDFDocument("");
+        PDFFactory pdfFactory = new PDFFactory(doc);
+        SingleByteFont sb = new TestSingleByteFont(null);
+        sb.setFontType(FontType.TRUETYPE);
+        sb.setFontName("test");
+        sb.setWidth(0, 0);
+        sb.setFlags(0);
+        sb.setEncoding(new CodePointMapping("FOPPDFEncoding", new int[0]));
+        String enc = "MacRomanEncoding";
+        PDFFont font = pdfFactory.makeFont("a", "a", enc, sb, sb);
+        font.output(new ByteArrayOutputStream());
+        assertEquals(((PDFName)font.entries.get("Encoding")).getName(), enc);
+    }
+
+    class TestSingleByteFont extends SingleByteFont {
+        public TestSingleByteFont(InternalResourceResolver resourceResolver) {
+            super(resourceResolver, EmbeddingMode.SUBSET);
+        }
+
+        public InputStream getInputStream() throws IOException {
+            File f = new File("test/resources/fonts/type1/a010013l.pfb");
+            return new FileInputStream(f);
+        }
+    }
+
+    @Test
     public void testMakeOTFFont() throws IOException {
         InternalResourceResolver rr =
                 ResourceResolverFactory.createDefaultInternalResourceResolver(new File(".").toURI());



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message