]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2546: ArrayIndexOutOfBoundsException merging fonts
authorSimon Steiner <ssteiner@apache.org>
Wed, 2 Dec 2015 14:18:41 +0000 (14:18 +0000)
committerSimon Steiner <ssteiner@apache.org>
Wed, 2 Dec 2015 14:18:41 +0000 (14:18 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1717634 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/pdf/PDFFactory.java

index ad117c9d09f3286db4d34c86bcf0806bb9445f74..e2c17b4e958b3dcff7f4e9bbbcb3921de6f8c87a 100644 (file)
@@ -981,27 +981,31 @@ public class PDFFactory {
                     //No ToUnicode CMap necessary if PDF 1.4, chapter 5.9 (page 368) is to be
                     //believed.
                 } else if (mapping.getName().equals("FOPPDFEncoding")) {
-                    String[] charNameMap = mapping.getCharNameMap();
-                    char[] intmap = mapping.getUnicodeCharMap();
-                    PDFArray differences = new PDFArray();
-                    int len = intmap.length;
-                    if (charNameMap.length < len) {
-                        len = charNameMap.length;
-                    }
-                    int last = 0;
-                    for (int i = 0; i < len; i++) {
-                        if (intmap[i] - 1 != last) {
-                            differences.add(intmap[i]);
+                    if (fonttype == FontType.TRUETYPE) {
+                        font.setEncoding("WinAnsiEncoding");
+                    } else {
+                        String[] charNameMap = mapping.getCharNameMap();
+                        char[] intmap = mapping.getUnicodeCharMap();
+                        PDFArray differences = new PDFArray();
+                        int len = intmap.length;
+                        if (charNameMap.length < len) {
+                            len = charNameMap.length;
+                        }
+                        int last = 0;
+                        for (int i = 0; i < len; i++) {
+                            if (intmap[i] - 1 != last) {
+                                differences.add(intmap[i]);
+                            }
+                            last = intmap[i];
+                            differences.add(new PDFName(charNameMap[i]));
+                        }
+                        PDFEncoding pdfEncoding = new PDFEncoding(singleByteFont.getEncodingName());
+                        getDocument().registerObject(pdfEncoding);
+                        pdfEncoding.setDifferences(differences);
+                        font.setEncoding(pdfEncoding);
+                        if (mapping.getUnicodeCharMap() != null) {
+                            generateToUnicodeCmap(nonBase14, mapping);
                         }
-                        last = intmap[i];
-                        differences.add(new PDFName(charNameMap[i]));
-                    }
-                    PDFEncoding pdfEncoding = new PDFEncoding(singleByteFont.getEncodingName());
-                    getDocument().registerObject(pdfEncoding);
-                    pdfEncoding.setDifferences(differences);
-                    font.setEncoding(pdfEncoding);
-                    if (mapping.getUnicodeCharMap() != null) {
-                        generateToUnicodeCmap(nonBase14, mapping);
                     }
                 } else {
                     Object pdfEncoding = createPDFEncoding(mapping,