aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2014-05-09 17:48:02 -0400
committerBehdad Esfahbod <behdad@behdad.org>2014-05-09 17:48:02 -0400
commite898881ed12d7ce96948f2905d725847c76bc9e8 (patch)
tree89b1223ac663d291575b397859763b1802a2c227
parentda223b8fa8a1073f96b3d2c8e400f73e51941b71 (diff)
downloadfonttools-e898881ed12d7ce96948f2905d725847c76bc9e8.tar.gz
[subset] Implement format14 variation selectors
-rw-r--r--Lib/fontTools/subset.py23
1 files 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():