git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1739076 13f79535-47bb-0310-9956-ffa450edef68tags/fop-2_2
@@ -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> |
@@ -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(); |
@@ -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", |
@@ -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); |