colorLib: let clipBoxes contain more glyphs than colorGlyphs, helps with sparse variable builds

This commit is contained in:
Cosimo Lupo 2022-07-04 16:53:16 +01:00
parent eb00e499c0
commit 3b0769b519
2 changed files with 3 additions and 4 deletions

View File

@ -248,9 +248,6 @@ def buildCOLR(
if version == 0: if version == 0:
self.ColorLayers = self._decompileColorLayersV0(colr) self.ColorLayers = self._decompileColorLayersV0(colr)
else: else:
clipBoxes = {
name: clipBoxes[name] for name in clipBoxes or {} if name in colorGlyphsV1
}
colr.ClipList = buildClipList(clipBoxes) if clipBoxes else None colr.ClipList = buildClipList(clipBoxes) if clipBoxes else None
colr.VarIndexMap = varIndexMap colr.VarIndexMap = varIndexMap
colr.VarStore = varStore colr.VarStore = varStore

View File

@ -1678,7 +1678,7 @@ class BuildCOLRTest(object):
clipBoxes={ clipBoxes={
"a": (0, 0, 1000, 1000, 0), # optional 5th: varIndexBase "a": (0, 0, 1000, 1000, 0), # optional 5th: varIndexBase
"c": (-100.8, -200.4, 1100.1, 1200.5), # floats get rounded "c": (-100.8, -200.4, 1100.1, 1200.5), # floats get rounded
"e": (0, 0, 10, 10), # missing base glyph 'e' is ignored "e": (0, 0, 10, 10), # 'e' does _not_ get ignored despite being missing
}, },
) )
@ -1689,9 +1689,11 @@ class BuildCOLRTest(object):
] == [ ] == [
("a", (0, 0, 1000, 1000, 0)), ("a", (0, 0, 1000, 1000, 0)),
("c", (-101, -201, 1101, 1201)), ("c", (-101, -201, 1101, 1201)),
("e", (0, 0, 10, 10)),
] ]
assert clipBoxes["a"].Format == 2 assert clipBoxes["a"].Format == 2
assert clipBoxes["c"].Format == 1 assert clipBoxes["c"].Format == 1
assert clipBoxes["e"].Format == 1
def test_duplicate_base_glyphs(self): def test_duplicate_base_glyphs(self):
# If > 1 base glyphs refer to equivalent list of layers we expect them to share # If > 1 base glyphs refer to equivalent list of layers we expect them to share