From f615b400c6a4f79a9d6269cf60b3754c06ecf751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Thu, 5 Dec 2024 22:56:35 -0300 Subject: [PATCH] Deprecate 'kerning_for_non_ligated_sequences' (Universal Profile) "Is there kerning info for non-ligated sequences?" (issue #2954 / https://github.com/simoncozens/fontspector/commit/eaa52447ddc4a42e26b6430841a43026870d8a48) --- CHANGELOG.md | 4 +- .../kerning_for_non_ligated_sequences.py | 97 ------------------- Lib/fontbakery/profiles/adobefonts.py | 1 - Lib/fontbakery/profiles/fontbureau.py | 1 - Lib/fontbakery/profiles/microsoft.py | 1 - Lib/fontbakery/profiles/typenetwork.py | 7 -- Lib/fontbakery/profiles/universal.py | 1 - tests/test_checks_kerning.py | 55 ----------- 8 files changed, 3 insertions(+), 164 deletions(-) delete mode 100644 Lib/fontbakery/checks/kerning_for_non_ligated_sequences.py delete mode 100644 tests/test_checks_kerning.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 82e0ebc277..ac5eaf1786 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,9 @@ Below are the noteworthy changes from each release. A more detailed list of changes is available in the corresponding milestones for each release in the Github issue tracker (https://github.com/googlefonts/fontbakery/milestones?state=closed). ## Upcoming release: 0.13.0 (2024-Dec-??) - - ... +### Deprecated checks +#### On the Universal Profile + - **[kerning_for_non_ligated_sequences]**: "Is there kerning info for non-ligated sequences?" (issue #2954 / https://github.com/simoncozens/fontspector/commit/eaa52447ddc4a42e26b6430841a43026870d8a48) ## 0.13.0a6 (2024-Dec-03) diff --git a/Lib/fontbakery/checks/kerning_for_non_ligated_sequences.py b/Lib/fontbakery/checks/kerning_for_non_ligated_sequences.py deleted file mode 100644 index 1514ae307a..0000000000 --- a/Lib/fontbakery/checks/kerning_for_non_ligated_sequences.py +++ /dev/null @@ -1,97 +0,0 @@ -from fontbakery.prelude import check, condition, Message, FAIL, WARN -from fontbakery.testable import Font -from fontbakery.utils import bullet_list - - -@condition(Font) -def ligatures(font): - from fontTools.ttLib.tables.otTables import LigatureSubst - - ttFont = font.ttFont - all_ligatures = {} - try: - if "GSUB" in ttFont and ttFont["GSUB"].table.LookupList: - for record in ttFont["GSUB"].table.FeatureList.FeatureRecord: - if record.FeatureTag == "liga": - for index in record.Feature.LookupListIndex: - lookup = ttFont["GSUB"].table.LookupList.Lookup[index] - for subtable in lookup.SubTable: - if isinstance(subtable, LigatureSubst): - for firstGlyph in subtable.ligatures.keys(): - all_ligatures[firstGlyph] = [] - for lig in subtable.ligatures[firstGlyph]: - if ( - lig.Component - not in all_ligatures[firstGlyph] - ): - all_ligatures[firstGlyph].append( - lig.Component - ) - return all_ligatures - except (AttributeError, IndexError): - return -1 # Indicate fontTools-related crash... - - -@check( - id="kerning_for_non_ligated_sequences", - conditions=["ligatures", "has_kerning_info"], - rationale=""" - Fonts with ligatures should have kerning on the corresponding non-ligated - sequences for text where ligatures aren't used - (eg https://github.com/impallari/Raleway/issues/14). - """, - proposal="https://github.com/fonttools/fontbakery/issues/1145", -) -def check_kerning_for_non_ligated_sequences(ttFont, config, ligatures): - """Is there kerning info for non-ligated sequences?""" - - def look_for_nonligated_kern_info(table): - for pairpos in table.SubTable: - for i, glyph in enumerate(pairpos.Coverage.glyphs): - if not hasattr(pairpos, "PairSet"): - continue - for pairvalue in pairpos.PairSet[i].PairValueRecord: - kern_pair = (glyph, pairvalue.SecondGlyph) - if kern_pair in ligature_pairs: - ligature_pairs.remove(kern_pair) - - def ligatures_sequences(pairs): - return [f"{first} + {second}" for first, second in pairs] - - def make_pairs(first, components): - pairs = [] - while components: - pairs.append((first, components[0])) - first = components.pop(0) - return pairs - - if ligatures == -1: - yield FAIL, Message( - "malformed", - "Failed to lookup ligatures." - " This font file seems to be malformed." - " For more info, read:" - " https://github.com/fonttools/fontbakery/issues/1596", - ) - else: - ligature_pairs = set() - for first, comp in ligatures.items(): - for components in comp: - pairs = make_pairs(first, components) - ligature_pairs.update(pairs) - - ligature_pairs = sorted(ligature_pairs) - - for record in ttFont["GSUB"].table.FeatureList.FeatureRecord: - if record.FeatureTag == "kern": - for index in record.Feature.LookupListIndex: - lookup = ttFont["GSUB"].table.LookupList.Lookup[index] - look_for_nonligated_kern_info(lookup) - - if ligature_pairs: - yield WARN, Message( - "lacks-kern-info", - f"GPOS table lacks kerning info for the following" - f" non-ligated sequences:\n\n" - f"{bullet_list(config, ligatures_sequences(ligature_pairs))}", - ) diff --git a/Lib/fontbakery/profiles/adobefonts.py b/Lib/fontbakery/profiles/adobefonts.py index cfacf1962a..a519813d6d 100644 --- a/Lib/fontbakery/profiles/adobefonts.py +++ b/Lib/fontbakery/profiles/adobefonts.py @@ -59,7 +59,6 @@ "hinting_impact", "integer_ppem_if_hinted", "interpolation_issues", - "kerning_for_non_ligated_sequences", "legacy_accents", "ligature_carets", "mandatory_avar_table", diff --git a/Lib/fontbakery/profiles/fontbureau.py b/Lib/fontbakery/profiles/fontbureau.py index 49810faa18..b804d33c10 100644 --- a/Lib/fontbakery/profiles/fontbureau.py +++ b/Lib/fontbakery/profiles/fontbureau.py @@ -18,7 +18,6 @@ "hinting_impact", "inconsistencies_between_fvar_STAT", "integer_ppem_if_hinted", - "kerning_for_non_ligated_sequences", "ligature_carets", "mandatory_avar_table", "missing_small_caps_glyphs", diff --git a/Lib/fontbakery/profiles/microsoft.py b/Lib/fontbakery/profiles/microsoft.py index a780af4ef2..40b18d31b9 100644 --- a/Lib/fontbakery/profiles/microsoft.py +++ b/Lib/fontbakery/profiles/microsoft.py @@ -30,7 +30,6 @@ "hinting_impact", "inconsistencies_between_fvar_STAT", "integer_ppem_if_hinted", - "kerning_for_non_ligated_sequences", "ligature_carets", "mandatory_avar_table", "missing_small_caps_glyphs", diff --git a/Lib/fontbakery/profiles/typenetwork.py b/Lib/fontbakery/profiles/typenetwork.py index d7162e4653..7d33e3bf6c 100644 --- a/Lib/fontbakery/profiles/typenetwork.py +++ b/Lib/fontbakery/profiles/typenetwork.py @@ -110,13 +110,6 @@ "reason": "This is a feature, not really needed to the font perform well.", }, ], - "kerning_for_non_ligated_sequences": [ - { - "code": "lacks-kern-info", - "status": "INFO", - "reason": "This is a feature, not really needed to the font perform well.", - }, - ], "googlefonts/varfont/bold_wght_coord": [ { "code": "no-bold-instance", diff --git a/Lib/fontbakery/profiles/universal.py b/Lib/fontbakery/profiles/universal.py index c91764b08d..aa3877c81e 100644 --- a/Lib/fontbakery/profiles/universal.py +++ b/Lib/fontbakery/profiles/universal.py @@ -53,7 +53,6 @@ "legacy_accents", "ligature_carets", "linegaps", - "kerning_for_non_ligated_sequences", "mandatory_avar_table", "mandatory_glyphs", "math_signs_width", diff --git a/tests/test_checks_kerning.py b/tests/test_checks_kerning.py deleted file mode 100644 index 2ac7fdfb5e..0000000000 --- a/tests/test_checks_kerning.py +++ /dev/null @@ -1,55 +0,0 @@ -from fontTools.ttLib import TTFont - -from conftest import check_id -from fontbakery.codetesting import ( - # assert_PASS, FIXME: We must also have PASS test-cases! - assert_results_contain, - TEST_FILE, - MockFont, -) -from fontbakery.status import FAIL, WARN, SKIP - - -@check_id("kerning_for_non_ligated_sequences") -def test_check_kerning_for_non_ligated_sequences(check): - """Is there kerning info for non-ligated sequences ?""" - - # Our reference Mada Medium doesn't have a GSUB 'liga' feature, so it is skipped - # because of an unfulfilled condition. - ttFont = TTFont(TEST_FILE("mada/Mada-Medium.ttf")) - msg = assert_results_contain(check(ttFont), SKIP, "unfulfilled-conditions") - assert "Unfulfilled Conditions: ligatures" in msg - - # Simulate an error coming from the 'ligatures' condition; - # this is to exercise the 'malformed' code path. - font = TEST_FILE("mada/Mada-Medium.ttf") - msg = assert_results_contain( - check(MockFont(file=font, ligatures=-1)), FAIL, "malformed" - ) - assert "Failed to lookup ligatures. This font file seems to be malformed." in msg - - # And Merriweather Regular doesn't have a GPOS 'kern' feature, so it is skipped - # because of an unfulfilled condition. - ttFont = TTFont(TEST_FILE("merriweather/Merriweather-Regular.ttf")) - msg = assert_results_contain(check(ttFont), SKIP, "unfulfilled-conditions") - assert "Unfulfilled Conditions: has_kerning_info" in msg - - # SourceSansPro Bold is known to not kern the non-ligated glyph sequences. - ttFont = TTFont(TEST_FILE("source-sans-pro/OTF/SourceSansPro-Bold.otf")) - msg = assert_results_contain(check(ttFont), WARN, "lacks-kern-info") - assert msg == ( - "GPOS table lacks kerning info for the following non-ligated sequences:\n\n" - "\t- f + f\n\n\t- f + t" - ) - - # Simulate handling of multi-component ligatures - font = TEST_FILE("source-sans-pro/OTF/SourceSansPro-Bold.otf") - msg = assert_results_contain( - check(MockFont(file=font, ligatures={"f": [["f", "i"], ["f", "l"]]})), - WARN, - "lacks-kern-info", - ) - assert msg == ( - "GPOS table lacks kerning info for the following non-ligated sequences:\n\n" - "\t- f + f\n\n\t- f + i\n\n\t- f + l" - )