From adce6da98782037c3802a76aad195c11fb9cb929 Mon Sep 17 00:00:00 2001 From: Simon Steiner Date: Wed, 2 Dec 2015 14:18:41 +0000 Subject: [PATCH] FOP-2546: ArrayIndexOutOfBoundsException merging fonts 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 | 44 +++++++++++---------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/java/org/apache/fop/pdf/PDFFactory.java b/src/java/org/apache/fop/pdf/PDFFactory.java index ad117c9d0..e2c17b4e9 100644 --- a/src/java/org/apache/fop/pdf/PDFFactory.java +++ b/src/java/org/apache/fop/pdf/PDFFactory.java @@ -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, -- 2.39.5