[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:
parent
4ad6b0db13
commit
4a38610072
@ -2873,7 +2873,9 @@ def closure_glyphs(self, s):
|
|||||||
# Close glyphs
|
# Close glyphs
|
||||||
for table in tables:
|
for table in tables:
|
||||||
if table.format == 14:
|
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}
|
glyphs = {g for u, g in cmap if u in s.unicodes_requested}
|
||||||
if None in glyphs:
|
if None in glyphs:
|
||||||
glyphs.remove(None)
|
glyphs.remove(None)
|
||||||
@ -2927,7 +2929,7 @@ def subset_glyphs(self, s):
|
|||||||
for u, g in l
|
for u, g in l
|
||||||
if g in s.glyphs_requested or u in s.unicodes_requested
|
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}
|
t.uvsDict = {v: l for v, l in t.uvsDict.items() if l}
|
||||||
elif t.isUnicode():
|
elif t.isUnicode():
|
||||||
@ -3797,6 +3799,8 @@ def main(args=None):
|
|||||||
for t in font["cmap"].tables:
|
for t in font["cmap"].tables:
|
||||||
if t.isUnicode():
|
if t.isUnicode():
|
||||||
unicodes.extend(t.cmap.keys())
|
unicodes.extend(t.cmap.keys())
|
||||||
|
if t.format == 14:
|
||||||
|
unicodes.extend(t.uvsDict.keys())
|
||||||
assert "" not in glyphs
|
assert "" not in glyphs
|
||||||
|
|
||||||
log.info("Text: '%s'" % text)
|
log.info("Text: '%s'" % text)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user