diff options
author | Simon Steiner <ssteiner@apache.org> | 2016-04-14 12:40:55 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2016-04-14 12:40:55 +0000 |
commit | e5c576f3c070e5c7ec94b9d0d3e8d2071fdc6f82 (patch) | |
tree | bfe5586643163ef9f332bac1418edc7bacc7ae7d /fop-core | |
parent | d2ddc6abf6a66bf384b2b7fa132d18833b44a24b (diff) | |
download | xmlgraphics-fop-e5c576f3c070e5c7ec94b9d0d3e8d2071fdc6f82.tar.gz xmlgraphics-fop-e5c576f3c070e5c7ec94b9d0d3e8d2071fdc6f82.zip |
FOP-2562: Update to PDFBox 2
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1739076 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core')
4 files changed, 4 insertions, 66 deletions
diff --git a/fop-core/pom.xml b/fop-core/pom.xml index 22d921dc3..00ba4f08a 100644 --- a/fop-core/pom.xml +++ b/fop-core/pom.xml @@ -100,7 +100,7 @@ <dependency> <groupId>org.apache.pdfbox</groupId> <artifactId>fontbox</artifactId> - <version>1.8.5</version> + <version>2.0.0</version> </dependency> <!-- test deps --> <dependency> diff --git a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java index 9e6fed9d4..45c08391f 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFFile.java @@ -20,17 +20,10 @@ package org.apache.fop.fonts.truetype; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; import org.apache.fontbox.cff.CFFDataInput; import org.apache.fontbox.cff.CFFFont; import org.apache.fontbox.cff.CFFParser; -import org.apache.fontbox.cff.charset.CFFCharset; public class OTFFile extends OpenFont { @@ -56,44 +49,6 @@ public class OTFFile extends OpenFont { @Override protected void updateBBoxAndOffset() throws IOException { - List<Mapping> gidMappings = getGIDMappings(fileFont); - Map<Integer, String> sidNames = constructNameMap(gidMappings); - UnicodeMapping[] mappings = unicodeMappings.toArray(new UnicodeMapping[unicodeMappings.size()]); - for (int i = 0; i < mappings.length; i++) { - int glyphIdx = mappings[i].getGlyphIndex(); - Mapping m = gidMappings.get(glyphIdx); - String name = sidNames.get(m.getSID()); - mtxTab[glyphIdx].setName(name); - } - } - - private List<Mapping> getGIDMappings(CFFFont font) { - List<Mapping> gidMappings = new ArrayList<Mapping>(); - Mapping notdef = new Mapping(); - gidMappings.add(notdef); - for (CFFCharset.Entry entry : font.getCharset().getEntries()) { - String name = entry.getName(); - byte[] bytes = font.getCharStringsDict().get(name); - if (bytes == null) { - continue; - } - Mapping mapping = new Mapping(); - mapping.setSID(entry.getSID()); - mapping.setName(name); - mapping.setBytes(bytes); - gidMappings.add(mapping); - } - return gidMappings; - } - - private Map<Integer, String> constructNameMap(Collection<Mapping> mappings) { - Map<Integer, String> sidNames = new HashMap<Integer, String>(); - Iterator<Mapping> it = mappings.iterator(); - while (it.hasNext()) { - Mapping mapping = it.next(); - sidNames.put(mapping.getSID(), mapping.getName()); - } - return sidNames; } private static class Mapping { @@ -136,7 +91,7 @@ public class OTFFile extends OpenFont { } protected void readName() throws IOException { - Object familyName = fileFont.getProperty("FamilyName"); + Object familyName = fileFont.getTopDict().get("FamilyName"); if (familyName != null && !familyName.equals("")) { familyNames.add(familyName.toString()); fullName = familyName.toString(); diff --git a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java index a19399247..d8e363e99 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OTFSubSetFile.java @@ -35,7 +35,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.fontbox.cff.CFFStandardString; -import org.apache.fontbox.cff.encoding.CFFEncoding; import org.apache.fop.fonts.MultiByteFont; import org.apache.fop.fonts.cff.CFFDataReader; @@ -207,7 +206,6 @@ public class OTFSubSetFile extends OTFFile { //Encoding int encodingOffset = currentPos; - writeEncoding(fileFont.getEncoding()); //Charset table int charsetOffset = currentPos; @@ -271,20 +269,6 @@ public class OTFSubSetFile extends OTFFile { } } - private void writeEncoding(CFFEncoding encoding) throws IOException { - LinkedHashMap<String, DICTEntry> topDICT = cffReader.getTopDictEntries(); - DICTEntry encodingEntry = topDICT.get("Encoding"); - if (encodingEntry != null && encodingEntry.getOperands().get(0).intValue() != 0 - && encodingEntry.getOperands().get(0).intValue() != 1) { - writeByte(0); - writeByte(gidToSID.size()); - for (int gid : gidToSID.keySet()) { - int code = encoding.getCode(gidToSID.get(gid)); - writeByte(code); - } - } - } - protected void writeTopDICT() throws IOException { LinkedHashMap<String, DICTEntry> topDICT = cffReader.getTopDictEntries(); List<String> topDictStringEntries = Arrays.asList("version", "Notice", "Copyright", diff --git a/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java b/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java index 2048bcf46..efc91d121 100644 --- a/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFSubSetFileTestCase.java @@ -102,10 +102,9 @@ public class OTFSubSetFileTestCase extends OTFFileTestCase { throws IOException { CFFFont sourceSansOriginal = sourceSansProBold.fileFont; CFFIndexData charStrings = subsetCFF.getCharStringIndex(); - Map<String, byte[]> origCharStringData = sourceSansOriginal.getCharStringsDict(); + List<byte[]> origCharStringData = sourceSansOriginal.getCharStringBytes(); for (int i = 0; i < charStrings.getNumObjects(); i++) { - byte[] origCharData = origCharStringData.get(origCharStringData.keySet().toArray( - new String[0])[i]); + byte[] origCharData = origCharStringData.get(i); byte[] charData = charStrings.getValue(i); List<BytesNumber> origOperands = getFullCharString(new Context(), origCharData, origCFF); List<BytesNumber> subsetOperands = getFullCharString(new Context(), charData, subsetCFF); |