Skip to content

Commit

Permalink
Merge pull request #2424 from fonttools/subset-colrv1-no-cliplist
Browse files Browse the repository at this point in the history
[subset] fix AttributeError when subsetting COLRv1 font without optional ClipList
  • Loading branch information
anthrotype committed Oct 11, 2021
2 parents a5173b2 + 5c54f4e commit 71a986e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Lib/fontTools/subset/__init__.py
Expand Up @@ -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:
Expand Down
17 changes: 17 additions & 0 deletions Tests/subset/subset_test.py
Expand Up @@ -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"]
Expand Down

0 comments on commit 71a986e

Please sign in to comment.