diff --git a/Lib/fontTools/subset/__init__.py b/Lib/fontTools/subset/__init__.py index c2cdaff20e..c0f67e3670 100644 --- a/Lib/fontTools/subset/__init__.py +++ b/Lib/fontTools/subset/__init__.py @@ -2089,8 +2089,9 @@ def subset_glyphs(self, s): ) del self.ColorLayersV1 - clips = self.table.ClipList.clips - self.table.ClipList.clips = {g: clips[g] for g in clips if g in s.glyphs} + if self.table.ClipList is not None: + clips = self.table.ClipList.clips + self.table.ClipList.clips = {g: clips[g] for g in clips if g in s.glyphs} layersV0 = self.ColorLayers if not self.table.BaseGlyphList.BaseGlyphPaintRecord: diff --git a/Tests/subset/subset_test.py b/Tests/subset/subset_test.py index 4b3d9a843d..aeb4ce1d94 100644 --- a/Tests/subset/subset_test.py +++ b/Tests/subset/subset_test.py @@ -1269,6 +1269,23 @@ def test_subset_COLRv1_drop_all_v0_glyphs(colrv1_path): assert colr.table.LayerRecordCount is 0 +def test_subset_COLRv1_no_ClipList(colrv1_path): + font = TTFont(colrv1_path) + font["COLR"].table.ClipList = None # empty ClipList + font.save(colrv1_path) + + subset_path = colrv1_path.parent / (colrv1_path.name + ".subset") + subset.main( + [ + str(colrv1_path), + f"--output-file={subset_path}", + "--unicodes=*", + ] + ) + subset_font = TTFont(subset_path) + assert subset_font["COLR"].table.ClipList is None + + def test_subset_keep_size_drop_empty_stylistic_set(): fb = FontBuilder(unitsPerEm=1000, isTTF=True) glyph_order = [".notdef", "a", "b", "b.ss01"]