[subset] Implement format14 variation selectors
This commit is contained in:
parent
da223b8fa8
commit
e898881ed1
@ -1698,14 +1698,19 @@ def prune_post_subset(self, options):
|
|||||||
def closure_glyphs(self, s):
|
def closure_glyphs(self, s):
|
||||||
tables = [t for t in self.tables if t.isUnicode()]
|
tables = [t for t in self.tables if t.isUnicode()]
|
||||||
for u in s.unicodes_requested:
|
for u in s.unicodes_requested:
|
||||||
found = False
|
|
||||||
for table in tables:
|
for table in tables:
|
||||||
|
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:
|
if u in table.cmap:
|
||||||
s.glyphs.add(table.cmap[u])
|
s.glyphs.add(table.cmap[u])
|
||||||
found = True
|
found = True
|
||||||
break
|
|
||||||
if not found:
|
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'))
|
@_add_method(ttLib.getTableClass('cmap'))
|
||||||
def prune_pre_subset(self, options):
|
def prune_pre_subset(self, options):
|
||||||
@ -1731,8 +1736,10 @@ def subset_glyphs(self, s):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
if t.format == 14:
|
if t.format == 14:
|
||||||
# TODO(behdad) XXX We drop all the default-UVS mappings(g==None).
|
# TODO(behdad) We drop all the default-UVS mappings for glyphs_requested.
|
||||||
t.uvsDict = dict((v,[(u,g) for u,g in l if g in s.glyphs])
|
# 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())
|
for v,l in t.uvsDict.items())
|
||||||
t.uvsDict = dict((v,l) for v,l in t.uvsDict.items() if l)
|
t.uvsDict = dict((v,l) for v,l in t.uvsDict.items() if l)
|
||||||
elif t.isUnicode():
|
elif t.isUnicode():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user