From 00ad60b4c3c499a8845a9aaeb1a068a9974d3904 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Fri, 30 Aug 2024 18:13:26 +0100 Subject: [PATCH] subset_test: add failing test to reproduce issue #3616 If we subset this test font (a subset of Google Fonts' Andika-Regular.ttf) and request to keep 'cv43', only the FirstParaUILabelNameID (324) is currently kept, the other two (325 amd 326) get incorectly dropped. All referenced nameIDs should be kept. This will be fixed with https://github.com/fonttools/fonttools/pull/3617 ``` > assert nameIDs == keepNameIDs E assert {0, 1, 2, 3, 4, 5, 6, 321, 322, 323, 324} == {0, 1, 2, 3, 4, 5, 6, 321, 322, 323, 324, 325, 326} E Extra items in the right set: E 325 E 326 E Full diff: E - {0, 1, 2, 3, 4, 5, 6, 321, 322, 323, 324, 325, 326} E ? ---------- E + {0, 1, 2, 3, 4, 5, 6, 321, 322, 323, 324} ``` --- Tests/subset/data/Andika-Regular.subset.ttx | 733 ++++++++++++++++++++ Tests/subset/subset_test.py | 23 + 2 files changed, 756 insertions(+) create mode 100644 Tests/subset/data/Andika-Regular.subset.ttx diff --git a/Tests/subset/data/Andika-Regular.subset.ttx b/Tests/subset/data/Andika-Regular.subset.ttx new file mode 100644 index 000000000..8fd28a7a9 --- /dev/null +++ b/Tests/subset/data/Andika-Regular.subset.ttx @@ -0,0 +1,733 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Copyright (c) 2004-2022 SIL International + + + Andika + + + Regular + + + SIL International: Andika Regular: 2022 + + + Andika + + + Version 6.101 + + + Andika + + + Capital Eng + + + Alternate forms of capital Eng + + + Ŋ + + + Lowercase no descender + + + Capital form + + + Lowercase short stem + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/subset/subset_test.py b/Tests/subset/subset_test.py index abb82687e..8fdee83b4 100644 --- a/Tests/subset/subset_test.py +++ b/Tests/subset/subset_test.py @@ -2071,5 +2071,28 @@ def test_prune_unused_user_name_IDs_with_keep_all(ttf_path): assert nameIDs == keepNameIDs +def test_cvXX_feature_params_nameIDs_are_retained(): + # https://github.com/fonttools/fonttools/issues/3616 + font = TTFont() + ttx = pathlib.Path(__file__).parent / "data" / "Andika-Regular.subset.ttx" + font.importXML(ttx) + + keepNameIDs = {n.nameID for n in font["name"].names} + + options = subset.Options() + options.glyph_names = True + # that's where the FeatureParamsCharacteVariants are stored + options.layout_features.append("cv43") + + subsetter = subset.Subsetter(options) + subsetter.populate(glyphs=font.getGlyphOrder()) + subsetter.subset(font) + + # we expect that all nameIDs are retained, including all the nameIDs + # used by the FeatureParamsCharacterVariants + nameIDs = {n.nameID for n in font["name"].names} + assert nameIDs == keepNameIDs + + if __name__ == "__main__": sys.exit(unittest.main())