[subset] consider variation selectors subsetting cmap14

cmap14 subsetting code was not considering variation selectors in the input unicode set when deciding which variant glyphs to keep. This updates subsetting to only keeps variant glyphs if their variation selector code point is in the input unicodes set.
This commit is contained in:
Garret Rieger 2024-10-23 20:50:45 +00:00
parent 4ad6b0db13
commit 4a38610072

View File

@ -2873,7 +2873,9 @@ def closure_glyphs(self, s):
# Close glyphs
for table in tables:
if table.format == 14:
for cmap in table.uvsDict.values():
for varSelector, cmap in table.uvsDict.items():
if varSelector not in s.unicodes_requested:
continue
glyphs = {g for u, g in cmap if u in s.unicodes_requested}
if None in glyphs:
glyphs.remove(None)
@ -2927,7 +2929,7 @@ def subset_glyphs(self, s):
for u, g in l
if g in s.glyphs_requested or u in s.unicodes_requested
]
for v, l in t.uvsDict.items()
for v, l in t.uvsDict.items() if v in s.unicodes_requested
}
t.uvsDict = {v: l for v, l in t.uvsDict.items() if l}
elif t.isUnicode():
@ -3797,6 +3799,8 @@ def main(args=None):
for t in font["cmap"].tables:
if t.isUnicode():
unicodes.extend(t.cmap.keys())
if t.format == 14:
unicodes.extend(t.uvsDict.keys())
assert "" not in glyphs
log.info("Text: '%s'" % text)