[subset] prevent CPAL nameIDs from being dropped

This commit is contained in:
Jack McCabe 2022-09-30 12:36:28 +01:00
parent 4901deab76
commit 70112b947d
2 changed files with 4 additions and 2 deletions

View File

@ -2553,6 +2553,10 @@ def prune_pre_subset(self, font, options):
if stat.table.AxisValueArray: if stat.table.AxisValueArray:
nameIDs.update([val_rec.ValueNameID for val_rec in stat.table.AxisValueArray.AxisValue]) 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]) 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: if '*' not in options.name_IDs:
self.names = [n for n in self.names if n.nameID in nameIDs] self.names = [n for n in self.names if n.nameID in nameIDs]
if not options.name_legacy: if not options.name_legacy:

View File

@ -1359,8 +1359,6 @@ def test_subset_COLRv1_and_CPALv1(colrv1_cpalv1_path):
assert "CPAL" in subset_font assert "CPAL" in subset_font
cpal = subset_font["CPAL"] cpal = subset_font["CPAL"]
name_table = subset_font["name"] name_table = subset_font["name"]
import pdb
pdb.set_trace()
assert [name_table.getDebugName(name_id) for name_id in cpal.paletteEntryLabels] == [ assert [name_table.getDebugName(name_id) for name_id in cpal.paletteEntryLabels] == [
# "first color", # The first color was pruned # "first color", # The first color was pruned
"second color", "second color",