From 5729fdb0e56d1ccb7bd8a8aaf6604cb08b6a1cd6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 9 Nov 2012 13:18:42 +0530 Subject: [PATCH] Preserve glyph ids when subsetting CFF tables --- src/calibre/utils/fonts/sfnt/cff/writer.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/calibre/utils/fonts/sfnt/cff/writer.py b/src/calibre/utils/fonts/sfnt/cff/writer.py index 753d56b18e..6f77dc4b98 100644 --- a/src/calibre/utils/fonts/sfnt/cff/writer.py +++ b/src/calibre/utils/fonts/sfnt/cff/writer.py @@ -122,14 +122,15 @@ class Subset(object): char_strings = Index() self.charname_map = OrderedDict() charsets = Charsets(strings) + charsets.extend(cff.charset[1:]) # .notdef is not included for i in xrange(self.cff.num_glyphs): cname = self.cff.charset.safe_lookup(i) - if cname in keep_charnames: - char_strings.append(self.cff.char_strings[i]) - self.charname_map[cname] = len(self.charname_map) - if i > 0: # .notdef is not included - charsets.append(cname) + ok = cname in keep_charnames + cs = self.cff.char_strings[i] if ok else b'' + char_strings.append(cs) + if ok: + self.charname_map[cname] = i # Add the strings char_strings.compile()