Skip to content

Commit

Permalink
[subset] prevent CPAL nameIDs from being dropped
Browse files Browse the repository at this point in the history
  • Loading branch information
jackmcDaMa committed Sep 30, 2022
1 parent 4901dea commit 70112b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Lib/fontTools/subset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2553,6 +2553,10 @@ def prune_pre_subset(self, font, options):
if stat.table.AxisValueArray:
nameIDs.update([val_rec.ValueNameID for val_rec in stat.table.AxisValueArray.AxisValue])
nameIDs.update([axis_rec.AxisNameID for axis_rec in stat.table.DesignAxisRecord.Axis])
cpal = font.get('CPAL')
if cpal and cpal.version == 1:
nameIDs.update(cpal.paletteLabels)
nameIDs.update(cpal.paletteEntryLabels)
if '*' not in options.name_IDs:
self.names = [n for n in self.names if n.nameID in nameIDs]
if not options.name_legacy:
Expand Down
2 changes: 0 additions & 2 deletions Tests/subset/subset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,8 +1359,6 @@ def test_subset_COLRv1_and_CPALv1(colrv1_cpalv1_path):
assert "CPAL" in subset_font
cpal = subset_font["CPAL"]
name_table = subset_font["name"]
import pdb
pdb.set_trace()
assert [name_table.getDebugName(name_id) for name_id in cpal.paletteEntryLabels] == [
# "first color", # The first color was pruned
"second color",
Expand Down

0 comments on commit 70112b9

Please sign in to comment.