From 3b0769b519e054fd5a73a2d3ac7881a73ab8d447 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Mon, 4 Jul 2022 16:53:16 +0100 Subject: [PATCH] colorLib: let clipBoxes contain more glyphs than colorGlyphs, helps with sparse variable builds --- Lib/fontTools/colorLib/builder.py | 3 --- Tests/colorLib/builder_test.py | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Lib/fontTools/colorLib/builder.py b/Lib/fontTools/colorLib/builder.py index 310259afd..4a64007e2 100644 --- a/Lib/fontTools/colorLib/builder.py +++ b/Lib/fontTools/colorLib/builder.py @@ -248,9 +248,6 @@ def buildCOLR( if version == 0: self.ColorLayers = self._decompileColorLayersV0(colr) else: - clipBoxes = { - name: clipBoxes[name] for name in clipBoxes or {} if name in colorGlyphsV1 - } colr.ClipList = buildClipList(clipBoxes) if clipBoxes else None colr.VarIndexMap = varIndexMap colr.VarStore = varStore diff --git a/Tests/colorLib/builder_test.py b/Tests/colorLib/builder_test.py index 7259db4d8..b76b3a3e3 100644 --- a/Tests/colorLib/builder_test.py +++ b/Tests/colorLib/builder_test.py @@ -1678,7 +1678,7 @@ class BuildCOLRTest(object): clipBoxes={ "a": (0, 0, 1000, 1000, 0), # optional 5th: varIndexBase "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)), ("c", (-101, -201, 1101, 1201)), + ("e", (0, 0, 10, 10)), ] assert clipBoxes["a"].Format == 2 assert clipBoxes["c"].Format == 1 + assert clipBoxes["e"].Format == 1 def test_duplicate_base_glyphs(self): # If > 1 base glyphs refer to equivalent list of layers we expect them to share