Preserve glyph ids when subsetting CFF tables

This commit is contained in:
Kovid Goyal 2012-11-09 13:18:42 +05:30
parent a509176037
commit 5729fdb0e5

View File

@ -122,14 +122,15 @@ class Subset(object):
char_strings = Index() char_strings = Index()
self.charname_map = OrderedDict() self.charname_map = OrderedDict()
charsets = Charsets(strings) charsets = Charsets(strings)
charsets.extend(cff.charset[1:]) # .notdef is not included
for i in xrange(self.cff.num_glyphs): for i in xrange(self.cff.num_glyphs):
cname = self.cff.charset.safe_lookup(i) cname = self.cff.charset.safe_lookup(i)
if cname in keep_charnames: ok = cname in keep_charnames
char_strings.append(self.cff.char_strings[i]) cs = self.cff.char_strings[i] if ok else b''
self.charname_map[cname] = len(self.charname_map) char_strings.append(cs)
if i > 0: # .notdef is not included if ok:
charsets.append(cname) self.charname_map[cname] = i
# Add the strings # Add the strings
char_strings.compile() char_strings.compile()