From e898881ed12d7ce96948f2905d725847c76bc9e8 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 9 May 2014 17:48:02 -0400 Subject: [subset] Implement format14 variation selectors --- Lib/fontTools/subset.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Lib/fontTools/subset.py b/Lib/fontTools/subset.py index f65a5a36..13071517 100644 --- a/Lib/fontTools/subset.py +++ b/Lib/fontTools/subset.py @@ -1698,14 +1698,19 @@ def prune_post_subset(self, options): def closure_glyphs(self, s): tables = [t for t in self.tables if t.isUnicode()] for u in s.unicodes_requested: - found = False for table in tables: - if u in table.cmap: - s.glyphs.add(table.cmap[u]) - found = True - break + if table.format == 14: + for l in table.uvsDict.values(): + # TODO(behdad) Speed this up! + gids = [g for uc,g in l if u == uc and g is not None] + s.glyphs.update(gids) + # Intentionally not setting found=True here. + else: + if u in table.cmap: + s.glyphs.add(table.cmap[u]) + found = True if not found: - s.log("No glyph for Unicode value %s; skipping." % u) + s.log("No default glyph for Unicode %04X found." % u) @_add_method(ttLib.getTableClass('cmap')) def prune_pre_subset(self, options): @@ -1731,8 +1736,10 @@ def subset_glyphs(self, s): except AttributeError: pass if t.format == 14: - # TODO(behdad) XXX We drop all the default-UVS mappings(g==None). - t.uvsDict = dict((v,[(u,g) for u,g in l if g in s.glyphs]) + # TODO(behdad) We drop all the default-UVS mappings for glyphs_requested. + # I don't think we care about that... + t.uvsDict = dict((v,[(u,g) for u,g in l + if g in s.glyphs or u in s.unicodes_requested]) for v,l in t.uvsDict.items()) t.uvsDict = dict((v,l) for v,l in t.uvsDict.items() if l) elif t.isUnicode(): -- cgit v1.2.3