From 98f3b03ecd8310357c4ef91c1d2185fd6b989f13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 16:15:50 -0300 Subject: [PATCH 01/46] Assume all is fine when no SubResult is yielded If INFO or DEBUG messages are yielded, we still treat it as a PASS. (issue #4612) --- Lib/fontbakery/codetesting.py | 12 ++++++++++-- Lib/fontbakery/result.py | 19 +++++-------------- tests/test_codetesting.py | 4 ++-- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Lib/fontbakery/codetesting.py b/Lib/fontbakery/codetesting.py index 495d544c98..0ead9974c7 100644 --- a/Lib/fontbakery/codetesting.py +++ b/Lib/fontbakery/codetesting.py @@ -25,7 +25,7 @@ setup_context, checks_by_id, ) -from fontbakery.status import PASS, DEBUG, ERROR, SKIP +from fontbakery.status import PASS, DEBUG, INFO, ERROR, SKIP from fontbakery.configuration import Configuration from fontbakery.message import Message from fontbakery.profile import Profile @@ -177,7 +177,15 @@ def GLYPHSAPP_TEST_FILE(f): def assert_PASS(check_results, reason="with a good font...", ignore_error=None): print(f"Test PASS {reason}") - subresult = check_results[-1] + + # We'll ignore INFO and DEBUG messages: + check_results = [r for r in check_results if r.status not in [INFO, DEBUG]] + + if not check_results: + subresult = Subresult(PASS, Message("ok", "All looks good!")) + else: + subresult = check_results[-1] + if ignore_error and subresult.status == ERROR: print(ignore_error) return None diff --git a/Lib/fontbakery/result.py b/Lib/fontbakery/result.py index f375b3a463..80c3749dfd 100644 --- a/Lib/fontbakery/result.py +++ b/Lib/fontbakery/result.py @@ -2,7 +2,7 @@ from typing import Optional from fontbakery.profile import Section -from fontbakery.status import Status, ERROR +from fontbakery.status import Status, PASS from fontbakery.callable import FontBakeryCheck from fontbakery.message import Message @@ -55,20 +55,11 @@ def extend(self, results): @property def summary_status(self): - """The highest status in the list of subresults. If there are no - subresults, we return ERROR, since the check was misbehaving.""" + """The highest status in the list of subresults.""" + if not self.results: + # assume that if no result was yielded, then everything is fine: + self.results = [Subresult(PASS, Message("ok", "All looks good!"))] _summary_status = max(result.status for result in self.results) - if _summary_status is None: - _summary_status = ERROR - self.append( - Subresult( - ERROR, - Message( - "no-status-received", - f"The check {self.identity.check} did not yield any status", - ), - ) - ) return _summary_status def getData(self, runner): diff --git a/tests/test_codetesting.py b/tests/test_codetesting.py index 1b350c0d37..348ab2f944 100644 --- a/tests/test_codetesting.py +++ b/tests/test_codetesting.py @@ -67,7 +67,7 @@ def test_assert_PASS_success(capsys): Subresult(SKIP, Message("skip", "SKIP message")), Subresult(PASS, pass_msg), ] - assert assert_PASS(results) == "PASS message [code: pass]" + assert_PASS(results) captured = capsys.readouterr() assert captured.out == f"Test PASS {pass_reason}\n" @@ -95,7 +95,7 @@ def test_assert_PASS_ignore_error_true(capsys): Subresult(PASS, Message("pass", "PASS message")), Subresult(ERROR, Message("error", error_msg)), ] - assert assert_PASS(results, ignore_error=ignore) is None + assert_PASS(results, ignore_error=ignore) captured = capsys.readouterr() assert captured.out == f"Test PASS {pass_reason}\n{ignore}\n" From 67da3aaf2e40519e46561bda357293f42a95b6be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 16:17:15 -0300 Subject: [PATCH 02/46] simplify PASS results - adobefonts profile (issue #4612) --- Lib/fontbakery/checks/adobefonts.py | 9 --------- tests/checks/adobefonts_test.py | 29 ++++++++++------------------- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/Lib/fontbakery/checks/adobefonts.py b/Lib/fontbakery/checks/adobefonts.py index 610ab4c6ed..ef3a95992c 100644 --- a/Lib/fontbakery/checks/adobefonts.py +++ b/Lib/fontbakery/checks/adobefonts.py @@ -28,8 +28,6 @@ def com_adobe_fonts_check_family_consistent_upm(ttFonts): "inconsistent-upem", f"Fonts have different units per em: {sorted(upm_set)}.", ) - else: - yield PASS, "Fonts have consistent units per em." def _quick_and_dirty_glyph_is_empty(font, glyph_name): @@ -238,8 +236,6 @@ def com_adobe_fonts_check_unsupported_tables(ttFont): "unsupported-tables", f"The following unsupported font tables were found:\n\n{unsupported_list}", ) - else: - yield PASS, "No unsupported tables were found." @check( @@ -255,7 +251,6 @@ def com_adobe_fonts_check_unsupported_tables(ttFont): ) def com_adobe_fonts_check_STAT_strings(ttFont): """Check correctness of STAT table strings""" - passed = True stat_table = ttFont["STAT"].table ital_slnt_axis_indices = [] for index, axis in enumerate(stat_table.DesignAxisRecord.Axis): @@ -277,7 +272,6 @@ def com_adobe_fonts_check_STAT_strings(ttFont): bad_values = set() for name in ttFont["name"].names: if name.nameID in nameIDs and "italic" in name.toUnicode().lower(): - passed = False bad_values.add(f"nameID {name.nameID}: {name.toUnicode()}") if bad_values: @@ -287,6 +281,3 @@ def com_adobe_fonts_check_STAT_strings(ttFont): f' should not contain "Italic":\n' f" {sorted(bad_values)}", ) - - if passed: - yield PASS, "Looks good!" diff --git a/tests/checks/adobefonts_test.py b/tests/checks/adobefonts_test.py index e4451bd872..1c352e6e59 100644 --- a/tests/checks/adobefonts_test.py +++ b/tests/checks/adobefonts_test.py @@ -54,19 +54,17 @@ def test_check_find_empty_letters(): """Validate that empty glyphs are found.""" check = CheckTester("com.adobe.fonts/check/find_empty_letters") - PASS_MSG = "No empty glyphs for letters found." - # this OT-CFF font has inked glyphs for all letters ttFont = TTFont(TEST_FILE("source-sans-pro/OTF/SourceSansPro-Regular.otf")) - assert assert_PASS(check(ttFont)) == PASS_MSG + assert_PASS(check(ttFont)) # this OT-CFF2 font has inked glyphs for all letters ttFont = TTFont(TEST_FILE("source-sans-pro/VAR/SourceSansVariable-Italic.otf")) - assert assert_PASS(check(ttFont)) == PASS_MSG + assert_PASS(check(ttFont)) # this TrueType font has inked glyphs for all letters ttFont = TTFont(TEST_FILE("source-sans-pro/TTF/SourceSansPro-Bold.ttf")) - assert assert_PASS(check(ttFont)) == PASS_MSG + assert_PASS(check(ttFont)) # Add 2 Korean hangul syllable characters to cmap table mapped to the 'space' glyph. # These characters are part of the set whose glyphs are allowed to be blank. @@ -99,8 +97,7 @@ def test_check_nameid_1_win_english(): check = CheckTester("com.adobe.fonts/check/nameid_1_win_english") ttFont = TTFont(TEST_FILE("source-sans-pro/OTF/SourceSansPro-Regular.otf")) - msg = assert_PASS(check(ttFont)) - assert msg == "Font contains a good Windows nameID 1 US-English record." + assert_PASS(check(ttFont)) name_table = ttFont["name"] nameid_1_win_eng_rec = _get_nameid_1_win_eng_record(name_table) @@ -131,8 +128,7 @@ def test_check_unsupported_tables(): check = CheckTester("com.adobe.fonts/check/unsupported_tables") ttFont = TTFont(TEST_FILE("nunito/Nunito-Regular.ttf")) - msg = assert_PASS(check(ttFont)) - assert msg == "No unsupported tables were found." + assert_PASS(check(ttFont)) ttFont = TTFont(TEST_FILE("hinting/Roboto-VF.ttf")) msg = assert_results_contain(check(ttFont), FAIL, "unsupported-tables") @@ -214,8 +210,7 @@ def test_check_override_family_win_ascent_and_descent(): # Now fix the value of 'OS/2.usWinAscent'. The overridden check should PASS. os2_table.usWinAscent = y_max - msg = assert_PASS(check(ttFont), PASS) - assert msg == "OS/2 usWinAscent & usWinDescent values look good!" + assert_PASS(check(ttFont), PASS) # Now mess up the 'OS/2.usWinDescent' value. The overridden check should just WARN. os2_table.usWinDescent = abs(y_min) - 10 @@ -248,8 +243,7 @@ def test_check_override_os2_metrics_match_hhea(): # Our reference Mada Black is know to be good here. ttFont = TTFont(TEST_FILE("mada/Mada-Black.ttf")) - msg = assert_PASS(check(ttFont), PASS) - assert msg == "OS/2.sTypoAscender/Descender values match hhea.ascent/descent." + assert_PASS(check(ttFont), PASS) os2_table = ttFont["OS/2"] hhea_table = ttFont["hhea"] @@ -404,8 +398,7 @@ def test_check_override_match_familyname_fullfont(): ) ttFont = TTFont(TEST_FILE("source-sans-pro/OTF/SourceSansPro-Semibold.otf")) - msg = assert_PASS(check(ttFont), PASS) - assert msg == "Full font name begins with the font family name." + assert_PASS(check(ttFont), PASS) # Change the Full Font Name string for Microsoft platform record full_font_name = "SourceSansPro-Semibold" @@ -431,8 +424,7 @@ def test_check_override_trailing_spaces(): ) ttFont = TTFont(TEST_FILE("source-sans-pro/OTF/SourceSansPro-Semibold.otf")) - msg = assert_PASS(check(ttFont), PASS) - assert msg == "No trailing spaces on name table entries." + assert_PASS(check(ttFont), PASS) # Add a trailing space to the License string for Microsoft platform record name_table = ttFont["name"] @@ -499,5 +491,4 @@ def test_check_STAT_strings(): ttFont = TTFont(TEST_FILE("slant_direction/Cairo_correct_slnt_axis.ttf")) ttFont["name"].setName("Italic", 286, 3, 1, 1033) # This should PASS with our check - msg = assert_results_contain(check(ttFont), PASS, "Looks good!") - assert msg == "Looks good!" + assert_PASS(check(ttFont)) From 74430e72d2db0a602ec963f092d676dbd948dd90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 16:18:17 -0300 Subject: [PATCH 03/46] simplify PASS results - fontbureau profile (issue #4612) --- Lib/fontbakery/checks/fontbureau.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Lib/fontbakery/checks/fontbureau.py b/Lib/fontbakery/checks/fontbureau.py index 16b6b53d76..2001e01326 100644 --- a/Lib/fontbakery/checks/fontbureau.py +++ b/Lib/fontbakery/checks/fontbureau.py @@ -1,4 +1,4 @@ -from fontbakery.prelude import check, FAIL, PASS, Message +from fontbakery.prelude import check, FAIL, Message @check( @@ -11,14 +11,12 @@ ) def io_github_abysstypeco_check_ytlc_sanity(ttFont): """Check if ytlc values are sane in vf""" - passed = True for axis in ttFont["fvar"].axes: if not axis.axisTag == "ytlc": continue if axis.minValue < 0 or axis.maxValue > 1000: - passed = False yield FAIL, Message( "invalid-range", f"The range of ytlc values" @@ -26,5 +24,3 @@ def io_github_abysstypeco_check_ytlc_sanity(ttFont): f" to the expected range of ytlc which" f" should be min value 0 to max value 1000", ) - if passed: - yield PASS, "ytlc is sane" From 9d8491d72941c293a394fea477ae9ff73698d1fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 16:20:03 -0300 Subject: [PATCH 04/46] simplify PASS results - fontwerk profile (issue #4612) --- Lib/fontbakery/checks/fontwerk.py | 30 +----------------------------- tests/checks/fontwerk_test.py | 3 +-- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/Lib/fontbakery/checks/fontwerk.py b/Lib/fontbakery/checks/fontwerk.py index afe47d1d1a..42bec7ad78 100644 --- a/Lib/fontbakery/checks/fontwerk.py +++ b/Lib/fontbakery/checks/fontwerk.py @@ -2,7 +2,7 @@ Checks for Fontwerk """ -from fontbakery.prelude import check, PASS, FAIL, INFO, Message +from fontbakery.prelude import check, FAIL, INFO, Message from fontbakery.constants import FsSelection, MacStyle @@ -23,14 +23,9 @@ def com_fontwerk_check_name_no_mac_entries(ttFont): """Check if font has Mac name table entries (platform=1)""" - passed = True for rec in ttFont["name"].names: if rec.platformID == 1: yield FAIL, Message("mac-names", f"Please remove name ID {rec.nameID}") - passed = False - - if passed: - yield PASS, "No Mac name table entries." @check( @@ -48,8 +43,6 @@ def com_fontwerk_check_vendor_id(ttFont): yield FAIL, Message( "bad-vendor-id", f"OS/2 VendorID is '{vendor_id}', but should be 'WERK'." ) - else: - yield PASS, f"OS/2 VendorID '{vendor_id}' is correct." @check( @@ -65,7 +58,6 @@ def com_fontwerk_check_names_match_default_fvar(ttFont): """Checking if names match default fvar instance name.""" from fontbakery.constants import NameID - passed = True default_axis_values = { axis.axisTag: axis.defaultValue for axis in ttFont["fvar"].axes } @@ -76,7 +68,6 @@ def com_fontwerk_check_names_match_default_fvar(ttFont): break if default_name_id is None: - passed = False yield FAIL, Message( "missing-default-name-id", "fvar is missing a default instance name ID." ) @@ -86,7 +77,6 @@ def com_fontwerk_check_names_match_default_fvar(ttFont): subfam_name = ttFont["name"].getDebugName(default_name_id) if subfam_name is None: - passed = False yield FAIL, Message( "missing-name-id", f"Name ID {default_name_id} stored in" @@ -118,10 +108,8 @@ def com_fontwerk_check_names_match_default_fvar(ttFont): continue if name_fam is None: - passed = False yield FAIL, Message("missing-name-id", "Missing name ID {fam_id}.") elif name_subfam is None: - passed = False yield FAIL, Message("missing-name-id", "Missing name ID {subfam_id}.") else: possible_names = [f"{name_fam} {name_subfam}"] @@ -129,16 +117,12 @@ def com_fontwerk_check_names_match_default_fvar(ttFont): possible_names.append(name_fam) if default_name not in possible_names: - passed = False yield FAIL, Message( "bad-name", f"Name {possible_names} does not match fvar" f" default name '{default_name}'", ) - if passed: - yield PASS, f"Name matches fvar default name '{default_name}'." - @check( id="com.fontwerk/check/weight_class_fvar", @@ -165,9 +149,6 @@ def com_fontwerk_check_weight_class_fvar(ttFont): f"but should match fvar default value '{fvar_value}'.", ) - else: - yield PASS, f"OS/2 usWeightClass '{os2_value}' matches fvar default value." - def is_covered_in_stat(ttFont, axis_tag, value): if "STAT" not in ttFont: @@ -219,7 +200,6 @@ def com_fontwerk_check_inconsistencies_between_fvar_stat(ttFont): return FAIL, Message( "missing-stat-table", "Missing STAT table in variable font." ) - passed = True fvar = ttFont["fvar"] name = ttFont["name"] @@ -231,7 +211,6 @@ def com_fontwerk_check_inconsistencies_between_fvar_stat(ttFont): f"The name ID {ins.subfamilyNameID} used in an" f" fvar instance is missing in the name table.", ) - passed = False continue for axis_tag, value in ins.coordinates.items(): @@ -241,13 +220,9 @@ def com_fontwerk_check_inconsistencies_between_fvar_stat(ttFont): f"{instance_name}: '{axis_tag}' axis value '{value}'" f" missing in STAT table.", ) - passed = False # TODO: Compare fvar instance name with constructed STAT table name. - if passed: - yield PASS, "STAT and fvar axis records are consistent." - @check( id="com.fontwerk/check/style_linking", @@ -286,8 +261,5 @@ def com_fontwerk_check_style_linking(ttFont, font): name_id_2_should_be = "Bold Italic" errs.append(f"name ID should be (most likely) '{name_id_2_should_be}'.") - if not errs: - yield PASS, "Style linking looks good." - for err in errs: yield FAIL, Message("style-linking-issue", err) diff --git a/tests/checks/fontwerk_test.py b/tests/checks/fontwerk_test.py index 4d71359ebc..fdd8710331 100644 --- a/tests/checks/fontwerk_test.py +++ b/tests/checks/fontwerk_test.py @@ -55,8 +55,7 @@ def test_check_inconsistencies_between_fvar_stat(): check = CheckTester("com.fontwerk/check/inconsistencies_between_fvar_stat") ttFont = TTFont(TEST_FILE("cabinvf/Cabin[wdth,wght].ttf")) - msg = assert_PASS(check(ttFont), "with a good varfont...") - assert msg == "STAT and fvar axis records are consistent." + assert_PASS(check(ttFont), "with a good varfont...") ttFont = TTFont(TEST_FILE("bad_fonts/fvar_stat_differences/AxisLocationVAR.ttf")) ttFont["name"].removeNames(nameID=277) From 62e220d745c3f5246216167fe653884aa2b0746b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 16:22:25 -0300 Subject: [PATCH 05/46] simplify PASS results - googlefonts profile (article) (issue #4612) --- Lib/fontbakery/checks/googlefonts/article.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/article.py b/Lib/fontbakery/checks/googlefonts/article.py index 62be1f7ac7..905f5c96d7 100644 --- a/Lib/fontbakery/checks/googlefonts/article.py +++ b/Lib/fontbakery/checks/googlefonts/article.py @@ -1,6 +1,6 @@ import os -from fontbakery.prelude import check, Message, PASS, FAIL, WARN +from fontbakery.prelude import check, Message, FAIL, WARN @check( @@ -39,11 +39,9 @@ def is_vector(filename): return True return False - passed = True article_dir = os.path.join(family_directory, "article") images_dir = os.path.join(family_directory, "article", "images") if not os.path.isdir(article_dir): - passed = False yield WARN, Message( "lacks-article", f"Family metadata at {family_directory} does not have an article.\n", @@ -62,7 +60,6 @@ def is_vector(filename): if is_vector(filename) or is_raster(filename) ] if misplaced_files: - passed = False yield WARN, Message( "misplaced-image-files", f"There are {len(misplaced_files)} image files in the `article`" @@ -84,7 +81,6 @@ def is_vector(filename): filesize = os.stat(filename).st_size if filesize > maxsize: - passed = False yield FAIL, Message( "filesize", f"`{filename}` has `{filesize} bytes`, but the maximum filesize" @@ -98,12 +94,8 @@ def is_vector(filename): w, h = dim if w > MAX_WIDTH or h > MAX_HEIGHT: - passed = False yield FAIL, Message( "image-too-large", f"Image is too large: `{w} x {h} pixels`\n\n" f"Max resulution allowed: `{MAX_WIDTH} x {MAX_HEIGHT} pixels`", ) - - if passed: - yield PASS, "All looks good!" From 66aae0fab2210fe18fb64612497c83043f17ff2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 16:24:51 -0300 Subject: [PATCH 06/46] simplify PASS results - googlefonts profile (axisregistry) (issue #4612) --- .../checks/googlefonts/axisregistry.py | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/axisregistry.py b/Lib/fontbakery/checks/googlefonts/axisregistry.py index 854768f90e..bb78ac0376 100644 --- a/Lib/fontbakery/checks/googlefonts/axisregistry.py +++ b/Lib/fontbakery/checks/googlefonts/axisregistry.py @@ -1,5 +1,5 @@ from functools import lru_cache -from fontbakery.prelude import check, Message, INFO, PASS, FAIL +from fontbakery.prelude import check, Message, INFO, FAIL from fontbakery.constants import PlatformID, WindowsEncodingID, WindowsLanguageID @@ -22,7 +22,6 @@ def GFAxisRegistry(): ) def com_google_fonts_check_gf_axisregistry_bounds(family_metadata): """Validate METADATA.pb axes values are within gf_axisregistry bounds.""" - passed = True for axis in family_metadata.axes: if axis.tag in GFAxisRegistry().keys(): expected = GFAxisRegistry()[axis.tag] @@ -30,7 +29,6 @@ def com_google_fonts_check_gf_axisregistry_bounds(family_metadata): axis.min_value < expected.min_value or axis.max_value > expected.max_value ): - passed = False yield FAIL, Message( "bad-axis-range", f"The range in the font variation axis" @@ -40,8 +38,6 @@ def com_google_fonts_check_gf_axisregistry_bounds(family_metadata): f" as defined on Google Fonts Axis Registry" f" (min:{expected.min_value} max:{expected.max_value}).", ) - if passed: - yield PASS, "OK" @check( @@ -73,19 +69,14 @@ def com_google_fonts_check_gf_axisregistry_bounds(family_metadata): ) def com_google_fonts_check_gf_axisregistry_valid_tags(family_metadata): """Validate METADATA.pb axes tags are defined in gf_axisregistry.""" - passed = True for axis in family_metadata.axes: if axis.tag not in GFAxisRegistry().keys(): - passed = False yield FAIL, Message( "bad-axis-tag", f"The font variation axis '{axis.tag}'" f" is not yet registered on Google Fonts Axis Registry.", ) - if passed: - yield PASS, "OK" - @check( id="com.google.fonts/check/gf_axisregistry/fvar_axis_defaults", @@ -116,13 +107,11 @@ def com_google_fonts_check_gf_axisregistry_fvar_axis_defaults(ttFont): Validate defaults on fvar table match registered fallback names in GFAxisRegistry. """ - passed = True for axis in ttFont["fvar"].axes: if axis.axisTag not in GFAxisRegistry(): continue fallbacks = GFAxisRegistry()[axis.axisTag].fallback if axis.defaultValue not in [f.value for f in fallbacks]: - passed = False yield FAIL, Message( "not-registered", f"The defaul value {axis.axisTag}:{axis.defaultValue} is not registered" @@ -131,8 +120,6 @@ def com_google_fonts_check_gf_axisregistry_fvar_axis_defaults(ttFont): " or adopted one of the existing fallback names for this axis:\n" f"\t{fallbacks}", ) - if passed: - yield PASS, "OK" @check( @@ -153,7 +140,6 @@ def com_google_fonts_check_STAT_gf_axisregistry_names(ttFont): def normalize_name(name): return "".join(name.split(" ")) - passed = True format4_entries = False if "STAT" not in ttFont: yield FAIL, "Font is missing STAT table." @@ -210,7 +196,6 @@ def normalize_name(name): is_value = axis_value.NominalValue if name not in expected_names: expected_names = ", ".join(expected_names) - passed = False yield FAIL, Message( "invalid-name", f"On the font variation axis '{axis.AxisTag}'," @@ -219,7 +204,6 @@ def normalize_name(name): " to the Google Fonts Axis Registry.", ) elif is_value != fallbacks[name_entry.toUnicode()]: - passed = False yield FAIL, Message( "bad-coordinate", f"Axis Value for '{axis.AxisTag}':'{name_entry.toUnicode()}' is" @@ -235,6 +219,3 @@ def normalize_name(name): " which is what these 'format 4' entries are designed to describe," " so this check will ignore them for now.", ) - - if passed: - yield PASS, "OK" From 5432d57a4655aaea00c41d4453ba96a348a6abac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 20:46:08 -0300 Subject: [PATCH 07/46] simplify PASS results - googlefonts profile (color) (issue #4612) --- Lib/fontbakery/checks/googlefonts/color.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/color.py b/Lib/fontbakery/checks/googlefonts/color.py index 6c3a7f9f66..9ca20a95b1 100644 --- a/Lib/fontbakery/checks/googlefonts/color.py +++ b/Lib/fontbakery/checks/googlefonts/color.py @@ -1,4 +1,4 @@ -from fontbakery.prelude import check, Message, PASS, FAIL, WARN +from fontbakery.prelude import check, Message, FAIL, WARN @check( @@ -24,7 +24,6 @@ ) def com_google_fonts_check_colorfont_tables(font, ttFont): """Check font has the expected color font tables.""" - passed = True NANOEMOJI_ADVICE = ( "You can do it by using the maximum_color tool provided by" " the nanoemoji project:\n" @@ -33,7 +32,6 @@ def com_google_fonts_check_colorfont_tables(font, ttFont): if "COLR" in ttFont: if ttFont["COLR"].version == 0 and "SVG " in ttFont: - passed = False yield FAIL, Message( "drop-svg", "Font has a COLR v0 table, which is already widely supported," @@ -45,7 +43,6 @@ def com_google_fonts_check_colorfont_tables(font, ttFont): and "SVG " not in ttFont and not font.is_variable_font ): - passed = False yield FAIL, Message( "add-svg", "Font has COLRv1 but no SVG table; for CORLv1, we require" @@ -55,7 +52,6 @@ def com_google_fonts_check_colorfont_tables(font, ttFont): if "SVG " in ttFont: if font.is_variable_font: - passed = False yield FAIL, Message( "variable-svg", "This is a variable font and SVG does not support" @@ -64,16 +60,12 @@ def com_google_fonts_check_colorfont_tables(font, ttFont): ) if "COLR" not in ttFont: - passed = False yield FAIL, Message( "add-colr", "Font only has an SVG table." " Please add a COLR table as well.\n" + NANOEMOJI_ADVICE, ) - if passed: - yield PASS, "Looks Good!" - @check( id="com.google.fonts/check/color_cpal_brightness", @@ -128,8 +120,6 @@ def color_brightness(hex_value): f" layers in question to current color (0xFFFF), or alter" f" the brightness of these layers significantly.", ) - else: - yield PASS, "Looks good!" @check( @@ -169,5 +159,3 @@ def com_google_fonts_check_empty_glyph_on_gid1_for_colrv0(ttFont): "This is a COLR font. As a workaround for a rendering bug in" " Windows 10, it needs an empty glyph to be in GID 1. " + SUGGESTED_FIX, ) - else: - yield PASS, "Looks good!" From 594fa199cb63ac058a6c8653c582bf03cf92e3f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 20:51:16 -0300 Subject: [PATCH 08/46] simplify PASS results - googlefonts profile (copyright) (issue #4612) --- .../checks/googlefonts/copyright.py | 40 ++----------------- 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/copyright.py b/Lib/fontbakery/checks/googlefonts/copyright.py index c3565ac92c..8e9c796d70 100644 --- a/Lib/fontbakery/checks/googlefonts/copyright.py +++ b/Lib/fontbakery/checks/googlefonts/copyright.py @@ -1,4 +1,4 @@ -from fontbakery.prelude import check, disable, Message, PASS, FAIL +from fontbakery.prelude import check, disable, Message, FAIL from fontbakery.checks.googlefonts.constants import ( DESCRIPTION_OF_EXPECTED_COPYRIGHT_STRING_FORMATTING, EXPECTED_COPYRIGHT_PATTERN, @@ -23,9 +23,7 @@ def com_google_fonts_check_metadata_valid_copyright(font_metadata): import re string = font_metadata.copyright.lower() - if re.search(EXPECTED_COPYRIGHT_PATTERN, string): - yield PASS, "METADATA.pb copyright string is good" - else: + if not re.search(EXPECTED_COPYRIGHT_PATTERN, string): yield FAIL, Message( "bad-notice-format", f"METADATA.pb: Copyright notices should match a pattern similar to:\n\n" @@ -50,15 +48,8 @@ def com_google_fonts_check_font_copyright(ttFont): import re from fontbakery.utils import get_name_entry_strings - passed = True for string in get_name_entry_strings(ttFont, NameID.COPYRIGHT_NOTICE): - if re.search(EXPECTED_COPYRIGHT_PATTERN, string.lower()): - yield PASS, ( - f"Name Table entry: Copyright field '{string}'" - f" matches canonical pattern." - ) - else: - passed = False + if not re.search(EXPECTED_COPYRIGHT_PATTERN, string.lower()): yield FAIL, Message( "bad-notice-format", f"Name Table entry: Copyright notices should match" @@ -66,8 +57,6 @@ def com_google_fonts_check_font_copyright(ttFont): f'"Copyright 2019 The Familyname Project Authors (git url)"\n\n' f'But instead we have got:\n\n"{string}"\n', ) - if passed: - yield PASS, "Name table copyright entries are good" @disable @@ -77,12 +66,7 @@ def com_google_fonts_check_glyphs_file_font_copyright(glyphsFile): import re string = glyphsFile.copyright.lower() - if re.search(EXPECTED_COPYRIGHT_PATTERN, string): - yield PASS, ( - f"Name Table entry: Copyright field '{string}'" - f" matches canonical pattern." - ) - else: + if not re.search(EXPECTED_COPYRIGHT_PATTERN, string): yield FAIL, Message( "bad-notice-format", f"Copyright notices should match" @@ -111,8 +95,6 @@ def com_google_fonts_check_metadata_copyright_max_length(font_metadata): "METADATA.pb: Copyright notice exceeds" " maximum allowed lengh of 500 characteres.", ) - else: - yield PASS, "Copyright notice string is shorter than 500 chars." @check( @@ -127,14 +109,12 @@ def com_google_fonts_check_metadata_copyright_max_length(font_metadata): def com_google_fonts_check_metadata_nameid_copyright(ttFont, font_metadata): """Copyright field for this font on METADATA.pb matches all copyright notice entries on the name table ?""" - passed = True for nameRecord in ttFont["name"].names: string = nameRecord.string.decode(nameRecord.getEncoding()) if ( nameRecord.nameID == NameID.COPYRIGHT_NOTICE and string != font_metadata.copyright ): - passed = False yield FAIL, Message( "mismatch", f"Copyright field for this font on METADATA.pb" @@ -142,11 +122,6 @@ def com_google_fonts_check_metadata_nameid_copyright(ttFont, font_metadata): f" a copyright notice entry on the name table:" f' "{string}"', ) - if passed: - yield PASS, ( - "Copyright field for this font on METADATA.pb matches" - " copyright notice entries on the name table." - ) @check( @@ -163,19 +138,12 @@ def com_google_fonts_check_name_copyright_length(ttFont): """Length of copyright notice must not exceed 500 characters.""" from fontbakery.utils import get_name_entries - passed = True for notice in get_name_entries(ttFont, NameID.COPYRIGHT_NOTICE): notice_str = notice.string.decode(notice.getEncoding()) if len(notice_str) > 500: - passed = False yield FAIL, Message( "too-long", f"The length of the following copyright notice" f" ({len(notice_str)}) exceeds 500 chars:" f' "{notice_str}"', ) - if passed: - yield PASS, ( - "All copyright notice name entries on the" - " 'name' table are shorter than 500 characters." - ) From 0b8cb3e8a703de38e6b5fd9454a83ec63a6efef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 20:54:56 -0300 Subject: [PATCH 09/46] simplify PASS results - googlefonts profile (description) (issue #4612) --- .../checks/googlefonts/description.py | 38 ++----------------- tests/checks/googlefonts_test.py | 11 ++---- 2 files changed, 7 insertions(+), 42 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/description.py b/Lib/fontbakery/checks/googlefonts/description.py index 9c14d47144..48afed11e9 100644 --- a/Lib/fontbakery/checks/googlefonts/description.py +++ b/Lib/fontbakery/checks/googlefonts/description.py @@ -1,6 +1,6 @@ import os -from fontbakery.prelude import check, condition, Message, INFO, PASS, FAIL, WARN, FATAL +from fontbakery.prelude import check, condition, Message, INFO, FAIL, WARN, FATAL from fontbakery.utils import exit_with_install_instructions from fontbakery.testable import Font @@ -76,13 +76,10 @@ def com_google_fonts_check_description_has_article(font): article_path = os.path.join(directory, "article", "ARTICLE.en_us.html") has_article = os.path.exists(article_path) article_is_empty = has_article and os.path.getsize(article_path) == 0 - description_is_empty = not font.description - ok = True if not font.is_noto and has_article: if not description_is_empty: - ok = False yield FAIL, Message( "description-and-article", "This font has both a DESCRIPTION.en_us.html file" @@ -90,32 +87,26 @@ def com_google_fonts_check_description_has_article(font): " description must be empty.", ) if article_is_empty: - ok = False yield FAIL, Message( "empty-article", "The ARTICLE.en_us.html file is empty.", ) elif font.is_noto: if not has_article: - ok = False yield FAIL, Message( "missing-article", "This is a Noto font but it lacks an ARTICLE.en_us.html file", ) if has_article and article_is_empty: - ok = False yield FAIL, Message( "empty-article", "The ARTICLE.en_us.html file is empty.", ) if not font.description or description_is_empty: - ok = False yield FAIL, Message( "empty-description", "This is a Noto font but it lacks a DESCRIPTION.en_us.html file", ) - if ok: - yield PASS, "Looks good!" @check( @@ -165,8 +156,6 @@ def com_google_fonts_check_description_has_unsupported_elements(description): f"Description.en_us.html contains unsupported" f" html element(s). Please remove: {found}", ) - else: - yield PASS, "DESCRIPTION.en_us.html contains correct elements" @check( @@ -218,7 +207,7 @@ def com_google_fonts_check_description_broken_links(description_html): except requests.exceptions.RequestException: broken_links.append(link) - if len(broken_links) > 0: + if broken_links: broken_links_list = "\n\t".join(broken_links) yield FAIL, Message( "broken-links", @@ -226,8 +215,6 @@ def com_google_fonts_check_description_broken_links(description_html): f" in the DESCRIPTION file:\n\t" f"{broken_links_list}", ) - else: - yield PASS, "All links in the DESCRIPTION file look good!" @check( @@ -247,7 +234,6 @@ def com_google_fonts_check_description_broken_links(description_html): ) def com_google_fonts_check_description_urls(description_html): """URLs on DESCRIPTION file must not display http(s) prefix.""" - passed = True for a_href in description_html.iterfind(".//a[@href]"): link_text = a_href.text if not link_text: @@ -260,7 +246,6 @@ def com_google_fonts_check_description_urls(description_html): continue if link_text.startswith("http://") or link_text.startswith("https://"): - passed = False yield FAIL, Message( "prefix-found", 'Please remove the "http(s)://" prefix from the text content' @@ -268,9 +253,6 @@ def com_google_fonts_check_description_urls(description_html): ) continue - if passed: - yield PASS, "All good!" - @check( id="com.google.fonts/check/description/git_url", @@ -298,9 +280,7 @@ def com_google_fonts_check_description_git_url(description_html): git_urls.append(link) yield INFO, Message("url-found", f"Found a git repo URL: {link}") - if len(git_urls) > 0: - yield PASS, "Looks great!" - else: + if not git_urls: yield FAIL, Message( "lacks-git-url", "Please host your font project on a public Git repo" @@ -334,7 +314,6 @@ def com_google_fonts_check_description_valid_html(descfile, description): except ImportError: exit_with_install_instructions("googlefonts") - passed = True if "" in description or "" in description: yield FAIL, Message( "html-tag", @@ -347,7 +326,6 @@ def com_google_fonts_check_description_valid_html(descfile, description): try: html.fromstring("" + description + "") except Exception as e: - passed = False yield FAIL, Message( "malformed-snippet", f"{descfile} does not look like a propper HTML snippet." @@ -360,14 +338,10 @@ def com_google_fonts_check_description_valid_html(descfile, description): ) if "

" not in description or "

" not in description: - passed = False yield FAIL, Message( "lacks-paragraph", f"{descfile} does not include an HTML

tag." ) - if passed: - yield PASS, f"{descfile} is a propper HTML file." - @check( id="com.google.fonts/check/description/min_length", @@ -389,8 +363,6 @@ def com_google_fonts_check_description_min_length(description): "too-short", "DESCRIPTION.en_us.html must have size larger than 200 bytes.", ) - else: - yield PASS, "DESCRIPTION.en_us.html is larger than 200 bytes." @check( @@ -415,8 +387,6 @@ def com_google_fonts_check_description_eof_linebreak(description): "The last characther on DESCRIPTION.en_us.html" " is not a line-break. Please add it.", ) - else: - yield PASS, ":-)" @check( @@ -446,5 +416,3 @@ def com_google_fonts_check_description_family_update(font, network): "Please consider mentioning note-worthy improvements made" " to the family recently.", ) - else: - yield PASS, "OK" diff --git a/tests/checks/googlefonts_test.py b/tests/checks/googlefonts_test.py index 0f0215adec..7f950c948f 100644 --- a/tests/checks/googlefonts_test.py +++ b/tests/checks/googlefonts_test.py @@ -201,19 +201,16 @@ def test_check_description_broken_links(): "with description file that has good links...", ) - good_desc += "An example mailto link" + bad_desc = ( + good_desc + "An example mailto link" + ) assert_results_contain( - check(MockFont(file=font, description=good_desc)), + check(MockFont(file=font, description=bad_desc)), FAIL, "email", 'with a description file containing "mailto" links...', ) - assert_PASS( - check(MockFont(file=font, description=good_desc)), - 'with a description file containing "mailto" links...', - ) - bad_desc = ( good_desc + "This is a Bad Link" From b390f110ac27a92ec5c16ad888786d26a0d13da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 20:56:05 -0300 Subject: [PATCH 10/46] simplify PASS results - googlefonts profile (family) (issue #4612) --- Lib/fontbakery/checks/googlefonts/family.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/family.py b/Lib/fontbakery/checks/googlefonts/family.py index cbe419d9cc..4fb9d252b5 100644 --- a/Lib/fontbakery/checks/googlefonts/family.py +++ b/Lib/fontbakery/checks/googlefonts/family.py @@ -1,5 +1,5 @@ import os -from fontbakery.prelude import check, Message, WARN, PASS, FAIL +from fontbakery.prelude import check, Message, WARN, FAIL from fontbakery.utils import bullet_list @@ -36,10 +36,6 @@ def com_google_fonts_check_family_equal_codepoint_coverage(fonts, config): if problems: yield FAIL, Message("glyphset-diverges", "\n".join(problems)) - else: - yield PASS, ( - "All font files in this family have an equivalent encoded glyphset." - ) @check( @@ -98,8 +94,6 @@ def com_google_fonts_check_family_italics_have_roman_counterparts(fonts, config) yield FAIL, Message( "missing-roman", f"Italics missing a Roman counterpart: {missing_roman}" ) - else: - yield PASS, "OK" @check( @@ -147,5 +141,3 @@ def com_google_fonts_check_family_tnum_horizontal_metrics(RIBBI_ttFonts): f" tabular glyphs with different widths" f" such as the following ones:\n\t{tnum_widths}.", ) - else: - yield PASS, "OK" From 0b262296fd99fd047f56704d8d304b3a38c64b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 20:56:56 -0300 Subject: [PATCH 11/46] simplify PASS results - googlefonts profile (gdef) (issue #4612) --- Lib/fontbakery/checks/googlefonts/gdef.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/gdef.py b/Lib/fontbakery/checks/googlefonts/gdef.py index 6b1b11c241..c62b5883ec 100644 --- a/Lib/fontbakery/checks/googlefonts/gdef.py +++ b/Lib/fontbakery/checks/googlefonts/gdef.py @@ -1,5 +1,5 @@ from fontbakery.testable import Font -from fontbakery.prelude import check, condition, PASS, FAIL, WARN, Message +from fontbakery.prelude import check, condition, FAIL, WARN, Message @condition(Font) @@ -83,5 +83,3 @@ def com_google_fonts_check_ligature_carets(ttFont, ligature_glyphs): f" values for these ligature glyphs:" f"\n\t- {missing}\n\n ", ) - else: - yield PASS, "Looks good!" From 7be3ecf533fe9642de997a43a40f3f1a2abcfc2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 20:58:02 -0300 Subject: [PATCH 12/46] simplify PASS results - googlefonts profile (glyf) (issue #4612) --- Lib/fontbakery/checks/googlefonts/glyf.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/glyf.py b/Lib/fontbakery/checks/googlefonts/glyf.py index 06b1e5f670..c92aceb456 100644 --- a/Lib/fontbakery/checks/googlefonts/glyf.py +++ b/Lib/fontbakery/checks/googlefonts/glyf.py @@ -1,4 +1,4 @@ -from fontbakery.prelude import check, disable, PASS, FAIL, Message +from fontbakery.prelude import check, disable, FAIL, Message # Disabling this check since the previous implementation was @@ -32,22 +32,18 @@ ) def com_google_fonts_check_negative_advance_width(ttFont): """Check that advance widths cannot be inferred as negative.""" - passed = True for glyphName in ttFont["glyf"].glyphs: coords = ttFont["glyf"][glyphName].coordinates rightX = coords[-3][0] leftX = coords[-4][0] advwidth = rightX - leftX if advwidth < 0: - passed = False yield FAIL, Message( "bad-coordinates", f'Glyph "{glyphName}" has bad coordinates on the glyf' f" table, which may lead to the advance width to be" f" interpreted as a negative value ({advwidth}).", ) - if passed: - yield PASS, "The x-coordinates of all glyphs look good." @check( @@ -84,5 +80,3 @@ def com_google_fonts_check_glyf_nested_components(ttFont, config): f" themselves are component glyphs:\n" f"{formatted_list}", ) - else: - yield PASS, ("Glyphs do not contain nested components.") From 84ba52bdb6f0c72595eec4424cf474cebb15a457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 21:01:26 -0300 Subject: [PATCH 13/46] simplify PASS results - googlefonts profile (glyphset) (issue #4612) --- Lib/fontbakery/checks/googlefonts/glyphset.py | 27 ++----------------- tests/checks/googlefonts_test.py | 2 +- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/glyphset.py b/Lib/fontbakery/checks/googlefonts/glyphset.py index 05a959ac70..8252d1afed 100644 --- a/Lib/fontbakery/checks/googlefonts/glyphset.py +++ b/Lib/fontbakery/checks/googlefonts/glyphset.py @@ -1,5 +1,5 @@ from fontbakery.constants import PANOSE_Family_Type -from fontbakery.prelude import check, condition, Message, PASS, FAIL, WARN, SKIP +from fontbakery.prelude import check, condition, Message, FAIL, WARN, SKIP from fontbakery.testable import Font from fontbakery.constants import ( NameID, @@ -89,22 +89,16 @@ def com_google_fonts_check_glyph_coverage(ttFont, family_metadata, config): else: required_glyphset = "GF_Latin_Core" - passed = True - if glyphsets_fulfilled[required_glyphset]["missing"]: missing = [ "0x%04X (%s)\n" % (c, unicodedata2.name(chr(c))) for c in glyphsets_fulfilled[required_glyphset]["missing"] ] - passed = False yield FAIL, Message( "missing-codepoints", f"Missing required codepoints:\n\n" f"{bullet_list(config, missing)}", ) - if passed: - yield PASS, "OK" - @check( id="com.google.fonts/check/glyphsets/shape_languages", @@ -126,8 +120,6 @@ def com_google_fonts_check_glyphsets_shape_languages(ttFont, config): shaperglot_checker = Checker(ttFont.reader.file.name) shaperglot_languages = Languages() - - passed = True any_glyphset_supported = False glyphsets_fulfilled = get_glyphsets_fulfilled(ttFont) @@ -163,7 +155,6 @@ def com_google_fonts_check_glyphsets_shape_languages(ttFont, config): fails_table.append(row) if fails_table: - passed = False yield FAIL, Message( "failed-language-shaping", f"{glyphset} glyphset:\n\n{markdown_table(fails_table)}\n\n", @@ -184,9 +175,6 @@ def com_google_fonts_check_glyphsets_shape_languages(ttFont, config): ), ) - if passed: - yield PASS, "OK." - @check( id="com.google.fonts/check/family/control_chars", @@ -265,8 +253,6 @@ def com_google_fonts_check_family_control_chars(ttFonts): bad = ", ".join(bad_fonts[fnt]) msg_unacceptable += f" {fnt}: {bad}\n" yield FAIL, Message("unacceptable", f"{msg_unacceptable}") - else: - yield PASS, ("Unacceptable control characters were not identified.") @check( @@ -299,8 +285,6 @@ def com_google_fonts_check_cjk_not_enough_glyphs(font): f"{cjk_glyphs}\n" f"Please check that these glyphs have the correct unicodes.", ) - else: - yield PASS, "Font has the correct quantity of CJK glyphs" @check( @@ -314,7 +298,6 @@ def com_google_fonts_check_cjk_not_enough_glyphs(font): def com_google_fonts_check_missing_small_caps_glyphs(ttFont): """Check small caps glyphs are available.""" - passed = True if "GSUB" in ttFont and ttFont["GSUB"].table.FeatureList is not None: llist = ttFont["GSUB"].table.LookupList for record in range(ttFont["GSUB"].table.FeatureList.FeatureCount): @@ -333,7 +316,6 @@ def com_google_fonts_check_missing_small_caps_glyphs(ttFont): smcp_glyphs = set(subtable.mapping.values()) missing = smcp_glyphs - set(ttFont.getGlyphNames()) if missing: - passed = False missing = "\n\t - " + "\n\t - ".join(missing) yield FAIL, Message( "missing-glyphs", @@ -341,9 +323,6 @@ def com_google_fonts_check_missing_small_caps_glyphs(ttFont): ) break - if passed: - yield PASS, "OK" - def can_shape(ttFont, text, parameters=None): """ @@ -381,9 +360,7 @@ def com_google_fonts_check_render_own_name(ttFont): ) .toUnicode() ) - if can_shape(ttFont, menu_name): - yield PASS, f"Font can successfully render its own name ({menu_name})" - else: + if not can_shape(ttFont, menu_name): yield FAIL, Message( "render-own-name", f".notdef glyphs were found when attempting to render {menu_name}", diff --git a/tests/checks/googlefonts_test.py b/tests/checks/googlefonts_test.py index 7f950c948f..c6fe4ac232 100644 --- a/tests/checks/googlefonts_test.py +++ b/tests/checks/googlefonts_test.py @@ -3872,7 +3872,7 @@ def test_check_cjk_vertical_metrics_regressions(): def test_check_cjk_not_enough_glyphs(): check = CheckTester("com.google.fonts/check/cjk_not_enough_glyphs") ttFont = TTFont(cjk_font) - assert assert_PASS(check(ttFont)) == ("Font has the correct quantity of CJK glyphs") + assert_PASS(check(ttFont)) ttFont = TTFont(TEST_FILE("montserrat/Montserrat-Regular.ttf")) msg = assert_results_contain(check(ttFont), SKIP, "unfulfilled-conditions") From d5d2d8f0e4afebcc4692531962174f49181df928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 21:02:28 -0300 Subject: [PATCH 14/46] simplify PASS results - googlefonts profile (gpos) (issue #4612) --- Lib/fontbakery/checks/googlefonts/gpos.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/gpos.py b/Lib/fontbakery/checks/googlefonts/gpos.py index 5b2b095551..c0f7d9f675 100644 --- a/Lib/fontbakery/checks/googlefonts/gpos.py +++ b/Lib/fontbakery/checks/googlefonts/gpos.py @@ -1,4 +1,4 @@ -from fontbakery.prelude import check, condition, Message, PASS, FAIL, WARN +from fontbakery.prelude import check, condition, Message, FAIL, WARN from fontbakery.testable import Font from fontbakery.utils import bullet_list @@ -90,7 +90,3 @@ def ligatures_sequences(pairs): f" non-ligated sequences:\n\n" f"{bullet_list(config, ligatures_sequences(ligature_pairs))}", ) - else: - yield PASS, ( - "GPOS table provides kerning info for all non-ligated sequences." - ) From 9e2b35b4c5430864a657ff67b4881fd38c96e623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 21:03:13 -0300 Subject: [PATCH 15/46] simplify PASS results - googlefonts profile (gsub) (issue #4612) --- Lib/fontbakery/checks/googlefonts/gsub.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/gsub.py b/Lib/fontbakery/checks/googlefonts/gsub.py index 1c2acf6754..6b67925e7c 100644 --- a/Lib/fontbakery/checks/googlefonts/gsub.py +++ b/Lib/fontbakery/checks/googlefonts/gsub.py @@ -1,4 +1,4 @@ -from fontbakery.prelude import check, Message, PASS, WARN +from fontbakery.prelude import check, Message, WARN @check( @@ -13,7 +13,6 @@ def com_google_fonts_check_stylisticset_description(ttFont): """Ensure Stylistic Sets have description.""" - passed = True if "GSUB" in ttFont and ttFont["GSUB"].table.FeatureList is not None: for record in range(ttFont["GSUB"].table.FeatureList.FeatureCount): feature = ttFont["GSUB"].table.FeatureList.FeatureRecord[record] @@ -25,7 +24,6 @@ def com_google_fonts_check_stylisticset_description(ttFont): assert "ss21" not in SSETS if tag in SSETS: if feature.Feature.FeatureParams is None: - passed = False yield WARN, Message( "missing-description", f"The stylistic set {tag} lacks" @@ -36,5 +34,3 @@ def com_google_fonts_check_stylisticset_description(ttFont): # that the referenced nameid does exist # in the name table. pass - if passed: - yield PASS, "OK" From bc2d7cc594e6d7de5066d7044ada7c9a6ea1c60c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 21:03:52 -0300 Subject: [PATCH 16/46] simplify PASS results - googlefonts profile (head) (issue #4612) --- Lib/fontbakery/checks/googlefonts/head.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/head.py b/Lib/fontbakery/checks/googlefonts/head.py index 2331d4757e..bff043e684 100644 --- a/Lib/fontbakery/checks/googlefonts/head.py +++ b/Lib/fontbakery/checks/googlefonts/head.py @@ -1,4 +1,4 @@ -from fontbakery.prelude import check, Message, PASS, FAIL +from fontbakery.prelude import check, Message, FAIL @check( @@ -32,5 +32,3 @@ def com_google_fonts_check_unitsperem_strict(ttFont): f" Good values for unitsPerEm," f" though, are typically these: {RECOMMENDED}.", ) - else: - yield PASS, f"Font em size is good (unitsPerEm = {upm_height})." From da048ee980389e147b2a3d2b18dac0b3423c132a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 21:09:11 -0300 Subject: [PATCH 17/46] simplify PASS results - googlefonts profile (hinting) (issue #4612) --- Lib/fontbakery/checks/googlefonts/hinting.py | 26 ++------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/hinting.py b/Lib/fontbakery/checks/googlefonts/hinting.py index 32539ce9bd..b930399673 100644 --- a/Lib/fontbakery/checks/googlefonts/hinting.py +++ b/Lib/fontbakery/checks/googlefonts/hinting.py @@ -99,7 +99,6 @@ def com_google_fonts_check_gasp(ttFont): "empty", "The 'gasp' table has no values.\n" + NON_HINTING_MESSAGE ) else: - passed = True if 0xFFFF not in ttFont["gasp"].gaspRange: yield WARN, Message( "lacks-ffff-range", @@ -140,21 +139,14 @@ def com_google_fonts_check_gasp(ttFont): f"The gasp table has a range of {key}" f" that may be unneccessary.", ) - passed = False else: value = ttFont["gasp"].gaspRange[0xFFFF] if value != 0x0F: - passed = False yield WARN, Message( "unset-flags", f"The gasp range 0xFFFF value 0x{value:02X}" f" should be set to 0x0F.", ) - if passed: - yield PASS, ( - "The 'gasp' table is correctly set, with one " - "gaspRange:value of 0xFFFF:0x0F." - ) @check( @@ -283,12 +275,6 @@ def ttfautohint_version(values): f" latest = {LATEST_TTFAUTOHINT_VERSION};" f" Need to re-run with the newer version!", ) - else: - yield PASS, ( - f"Font has been hinted with ttfautohint {ttfa_version}" - f" which is greater than or equal to the latest" - f" known version {LATEST_TTFAUTOHINT_VERSION}" - ) except ValueError: yield FAIL, Message( "parse-error", @@ -337,11 +323,7 @@ def com_google_fonts_check_smart_dropout(ttFont): """Font enables smart dropout control in "prep" table instructions?""" INSTRUCTIONS = b"\xb8\x01\xff\x85\xb0\x04\x8d" - if "prep" in ttFont and INSTRUCTIONS in ttFont["prep"].program.getBytecode(): - yield PASS, ( - "'prep' table contains instructions enabling smart dropout control." - ) - else: + if not ("prep" in ttFont and INSTRUCTIONS in ttFont["prep"].program.getBytecode()): yield FAIL, Message( "lacks-smart-dropout", "The 'prep' table does not contain TrueType" @@ -375,8 +357,6 @@ def com_google_fonts_check_vtt_clean(ttFont, vtt_talk_sources): f" to reduce total filesize:" f" {', '.join(vtt_talk_sources)}", ) - else: - yield PASS, "There are no tables with VTT Talk sources embedded in the font." @check( @@ -398,9 +378,7 @@ def com_google_fonts_check_vtt_clean(ttFont, vtt_talk_sources): def com_google_fonts_check_integer_ppem_if_hinted(ttFont): """PPEM must be an integer on hinted fonts.""" - if ttFont["head"].flags & (1 << 3): - yield PASS, "OK" - else: + if not ttFont["head"].flags & (1 << 3): yield FAIL, Message( "bad-flags", ( From 523084f2c92874dae41c7402c42f1919c16c59be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 21:10:28 -0300 Subject: [PATCH 18/46] simplify PASS results - googlefonts profile (hosted) (issue #4612) --- Lib/fontbakery/checks/googlefonts/hosted.py | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/hosted.py b/Lib/fontbakery/checks/googlefonts/hosted.py index 5d5b4182df..5e16a156b3 100644 --- a/Lib/fontbakery/checks/googlefonts/hosted.py +++ b/Lib/fontbakery/checks/googlefonts/hosted.py @@ -1,4 +1,4 @@ -from fontbakery.prelude import check, disable, Message, WARN, PASS, FAIL +from fontbakery.prelude import check, disable, Message, WARN, FAIL @check( @@ -18,43 +18,31 @@ def com_google_fonts_check_version_bump( v_number = ttFont["head"].fontRevision api_gfonts_v_number = api_gfonts_ttFont["head"].fontRevision github_gfonts_v_number = github_gfonts_ttFont["head"].fontRevision - passed = True if v_number == api_gfonts_v_number: - passed = False yield FAIL, ( f"Version number {v_number:0.3f} is" f" equal to version on **Google Fonts**." ) if v_number < api_gfonts_v_number: - passed = False yield FAIL, ( f"Version number {v_number:0.3f} is less than on" f" **Google Fonts** ({api_gfonts_v_number:0.3f})." ) if v_number == github_gfonts_v_number: - passed = False yield FAIL, ( f"Version number {v_number:0.3f} is equal to version on" f" google/fonts **GitHub repo**." ) if v_number < github_gfonts_v_number: - passed = False yield FAIL, ( f"Version number {v_number:0.3f} is less than on" f" google/fonts **GitHub repo** ({github_gfonts_v_number:0.3f})." ) - if passed: - yield PASS, ( - f"Version number {v_number:0.3f} is greater than on" - f" google/fonts **GitHub repo** ({github_gfonts_v_number:0.3f})" - f" and **production servers** ({api_gfonts_v_number:0.3f})." - ) - @check( id="com.google.fonts/check/production_glyphs_similarity", @@ -115,8 +103,6 @@ def glyphs_surface_area(ttFont): "Following glyphs differ greatly from" f" Google Fonts version:\n{formatted_list}" ) - else: - yield PASS, "Glyphs are similar in comparison to the Google Fonts version." # FIXME! @@ -146,5 +132,3 @@ def com_google_fonts_check_production_encoded_glyphs(ttFont, api_gfonts_ttFont): f" from the previous release" f" [{', '.join(hex_codepoints)}]", ) - else: - yield PASS, ("Font has all the glyphs from the previous release") From 76ef06c5c34c90070b61078e2caa84c8c83ab05e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 21:15:20 -0300 Subject: [PATCH 19/46] simplify PASS results - googlefonts profile (license) (issue #4612) --- Lib/fontbakery/checks/googlefonts/license.py | 28 ++------------------ 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/license.py b/Lib/fontbakery/checks/googlefonts/license.py index 9b2f4092fd..b787ee14c7 100644 --- a/Lib/fontbakery/checks/googlefonts/license.py +++ b/Lib/fontbakery/checks/googlefonts/license.py @@ -109,8 +109,6 @@ def com_google_fonts_check_family_has_license(licenses, config): " upstream repo, which is fine, just make sure" " there is a temporary license file in the same folder.", ) - else: - yield PASS, f"Found license at '{licenses[0]}'" @check( @@ -129,10 +127,7 @@ def com_google_fonts_check_license_OFL_copyright(license_contents): import re string = license_contents.strip().split("\n")[0].lower() - does_match = re.search(EXPECTED_COPYRIGHT_PATTERN, string) - if does_match: - yield PASS, "looks good" - else: + if not re.search(EXPECTED_COPYRIGHT_PATTERN, string): yield FAIL, Message( "bad-format", f"First line in license file is:\n\n" @@ -190,8 +185,6 @@ def com_google_fonts_check_license_OFL_body_text(license_contents): "Lines changed:\n\n" f"{output}\n\n", ) - else: - yield PASS, "OFL license body text is correct" @check( @@ -227,7 +220,6 @@ def com_google_fonts_check_name_license(ttFont, license_filename): """Check copyright namerecords match license file.""" from fontbakery.constants import PLACEHOLDER_LICENSING_TEXT - passed = True http_warn = False placeholder = PLACEHOLDER_LICENSING_TEXT[license_filename] entry_found = False @@ -247,7 +239,6 @@ def com_google_fonts_check_name_license(ttFont, license_filename): http_warn = True if "scripts.sil.org/OFL" in value: - passed = True yield WARN, Message( "old-url", "Please consider updating the url from " @@ -256,7 +247,6 @@ def com_google_fonts_check_name_license(ttFont, license_filename): ) return if value != placeholder: - passed = False yield FAIL, Message( "wrong", f"License file {license_filename} exists but" @@ -282,8 +272,6 @@ def com_google_fonts_check_name_license(ttFont, license_filename): f" (LICENSE DESCRIPTION). A proper licensing" f" entry must be set.", ) - elif passed: - yield PASS, "Licensing entry on name table is correctly set." @check( @@ -457,12 +445,7 @@ def com_google_fonts_check_name_license_url(ttFont, familyname): def com_google_fonts_check_metadata_license(family_metadata): """METADATA.pb license is "APACHE2", "UFL" or "OFL"?""" expected_licenses = ["APACHE2", "OFL", "UFL"] - if family_metadata.license in expected_licenses: - yield PASS, ( - f"Font license is declared in METADATA.pb" - f' as "{family_metadata.license}"' - ) - else: + if not family_metadata.license in expected_licenses: yield FAIL, Message( "bad-license", f'METADATA.pb license field ("{family_metadata.license}")' @@ -493,8 +476,6 @@ def com_google_fonts_check_epar(ttFont): "EPAR table not present in font. To learn more see" " https://github.com/fonttools/fontbakery/issues/818", ) - else: - yield PASS, "EPAR table present in font." # Although this is a /name/ check, it's really about licensing @@ -518,7 +499,6 @@ def com_google_fonts_check_epar(ttFont): ) def com_google_fonts_check_name_rfn(ttFont, familyname): """Name table strings must not contain the string 'Reserved Font Name'.""" - ok = True for entry in ttFont["name"].names: string = entry.toUnicode() if "This license is copied below, and is also available with a FAQ" in string: @@ -549,7 +529,3 @@ def com_google_fonts_check_name_rfn(ttFont, familyname): f" from the currently used family name ({familyname})," f" which is fine.", ) - ok = False - - if ok: - yield PASS, 'None of the name table strings contain "Reserved Font Name".' From 80c18f5244503808a13fc3e3db834827ec1efa94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Tue, 26 Mar 2024 16:20:32 -0300 Subject: [PATCH 20/46] simplify PASS results - googlefonts profile (metadata) (issue #4612) --- Lib/fontbakery/checks/googlefonts/metadata.py | 160 +----------------- 1 file changed, 4 insertions(+), 156 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/metadata.py b/Lib/fontbakery/checks/googlefonts/metadata.py index 7d342ba4a3..4fbd195ba6 100644 --- a/Lib/fontbakery/checks/googlefonts/metadata.py +++ b/Lib/fontbakery/checks/googlefonts/metadata.py @@ -65,8 +65,6 @@ def com_google_fonts_check_metadata_designer_values(family_metadata): f" '{family_metadata.designer}'." f" Please use commas to separate multiple names instead.", ) - else: - yield PASS, "Looks good." @check( @@ -85,7 +83,6 @@ def com_google_fonts_check_metadata_broken_links(family_metadata): """Does METADATA.pb copyright field contain broken links?""" import requests - passed = True broken_links = [] unique_links = [] for font_metadata in family_metadata.fonts: @@ -133,7 +130,6 @@ def com_google_fonts_check_metadata_broken_links(family_metadata): requests.codes.ok, requests.codes.too_many_requests, ]: - passed = False yield WARN, Message( "bad-github-url", f"Could not fetch '{link}'.\n\n" @@ -142,10 +138,8 @@ def com_google_fonts_check_metadata_broken_links(family_metadata): ) good = True if not good: - passed = False broken_links.append(("{} (status code: {})").format(link, code)) except requests.exceptions.Timeout: - passed = False yield WARN, Message( "timeout", f"Timed out while attempting to access: '{link}'." @@ -156,7 +150,6 @@ def com_google_fonts_check_metadata_broken_links(family_metadata): if len(broken_links) > 0: broken_links_list = "\n\t".join(broken_links) - passed = False yield FAIL, Message( "broken-links", f"The following links are broken" @@ -164,9 +157,6 @@ def com_google_fonts_check_metadata_broken_links(family_metadata): f"{broken_links_list}", ) - if passed: - yield PASS, "All links in the METADATA.pb file look good!" - @check( id="com.google.fonts/check/metadata/undeclared_fonts", @@ -187,14 +177,12 @@ def com_google_fonts_check_metadata_undeclared_fonts(family_metadata, family_dir for font_metadata in family_metadata.fonts: pb_binaries.append(font_metadata.filename) - passed = True binaries = [] for entry in os.listdir(family_directory): if entry != "static" and os.path.isdir(os.path.join(family_directory, entry)): for filename in os.listdir(os.path.join(family_directory, entry)): if filename[-4:] in [".ttf", ".otf"]: path = os.path.join(family_directory, entry, filename) - passed = False yield WARN, Message( "font-on-subdir", f'The file "{path}" is a font binary' @@ -209,7 +197,6 @@ def com_google_fonts_check_metadata_undeclared_fonts(family_metadata, family_dir binaries.append(entry) for filename in sorted(set(pb_binaries) - set(binaries)): - passed = False yield FAIL, Message( "file-missing", f'The file "{filename}" declared on METADATA.pb' @@ -217,14 +204,10 @@ def com_google_fonts_check_metadata_undeclared_fonts(family_metadata, family_dir ) for filename in sorted(set(binaries) - set(pb_binaries)): - passed = False yield FAIL, Message( "file-not-declared", f'The file "{filename}" is not declared on METADATA.pb' ) - if passed: - yield PASS, "OK" - @check( id="com.google.fonts/check/metadata/category", @@ -249,7 +232,6 @@ def com_google_fonts_check_metadata_undeclared_fonts(family_metadata, family_dir ) def com_google_fonts_check_metadata_category(family_metadata): """Ensure METADATA.pb category field is valid.""" - ok = True for category in family_metadata.category: if category not in [ "MONOSPACE", @@ -258,13 +240,10 @@ def com_google_fonts_check_metadata_category(family_metadata): "DISPLAY", "HANDWRITING", ]: - ok = False yield FAIL, Message( "bad-value", f'The field category has "{category}"' f" which is not valid.", ) - if ok: - yield PASS, "OK!" @check( @@ -297,8 +276,6 @@ def com_google_fonts_check_metadata_menu_and_latin(family_metadata): f'Subsets "menu" and "latin" are mandatory,' f" but METADATA.pb is missing {missing}.", ) - else: - yield PASS, 'METADATA.pb contains "menu" and "latin" subsets.' @check( @@ -324,8 +301,6 @@ def com_google_fonts_check_metadata_subsets_order(family_metadata): "" ).format("', '".join(family_metadata.subsets), "', '".join(expected)), ) - else: - yield PASS, "METADATA.pb subsets are sorted in alphabetical order." @check( @@ -353,8 +328,6 @@ def com_google_fonts_check_metadata_includes_production_subsets( "missing-subsets", f"The following subsets are missing [{', '.join(sorted(missing_subsets))}]", ) - else: - yield PASS, "No missing subsets" @check( @@ -379,8 +352,6 @@ def com_google_fonts_check_metadata_copyright(family_metadata, config): "The following copyright values were found:\n\n" + show_inconsistencies(copyrights, config), ) - else: - yield PASS, "Copyright is consistent across family" @check( @@ -405,10 +376,6 @@ def com_google_fonts_check_metadata_familyname(family_metadata, config): "The following name values were found:\n\n" + show_inconsistencies(names, config), ) - else: - yield PASS, ( - 'METADATA.pb: Family name is the same in all metadata "fonts" items.' - ) @check( @@ -422,9 +389,7 @@ def com_google_fonts_check_metadata_familyname(family_metadata, config): ) def com_google_fonts_check_metadata_has_regular(font): """Ensure there is a regular style defined in METADATA.pb.""" - if font.has_regular_style: - yield PASS, "Family has a Regular style." - else: + if not font.has_regular_style: yield FAIL, Message( "lacks-regular", "This family lacks a Regular" @@ -454,8 +419,6 @@ def com_google_fonts_check_metadata_regular_is_400(family_metadata): f"METADATA.pb: Regular font weight must be 400." f' Please fix these: {", ".join(badfonts)}', ) - else: - yield PASS, "Regular has weight = 400." @check( @@ -474,12 +437,10 @@ def com_google_fonts_check_metadata_nameid_post_script_name(ttFont, font_metadat """Checks METADATA.pb font.post_script_name matches postscript name declared on the name table. """ - passed = True from fontbakery.utils import get_name_entry_strings postscript_names = get_name_entry_strings(ttFont, NameID.POSTSCRIPT_NAME) if len(postscript_names) == 0: - passed = False yield FAIL, Message( "missing", ( @@ -491,7 +452,6 @@ def com_google_fonts_check_metadata_nameid_post_script_name(ttFont, font_metadat else: for psname in postscript_names: if psname != font_metadata.post_script_name: - passed = False yield FAIL, Message( "mismatch", ( @@ -500,11 +460,6 @@ def com_google_fonts_check_metadata_nameid_post_script_name(ttFont, font_metadat f' "{font_metadata.post_script_name}".' ), ) - if passed: - yield PASS, ( - f'Postscript name "{font_metadata.post_script_name}"' - f" is identical in METADATA.pb and on the TTF file." - ) # FIXME! This looks suspiciously similar to the now deprecated @@ -559,11 +514,6 @@ def com_google_fonts_check_metadata_nameid_font_name(ttFont, style, font_metadat f' TTF has familyname = "{font_familyname}" while' f' METADATA.pb has font.name = "{font_metadata.name}".', ) - else: - yield PASS, ( - f'OK: Family name "{font_metadata.name}" is identical' - f" in METADATA.pb and on the TTF file." - ) @check( @@ -594,11 +544,6 @@ def com_google_fonts_check_metadata_match_fullname_postscript(font_metadata): f" does not match" f' post_script_name = "{font_metadata.post_script_name}"', ) - else: - yield PASS, ( - 'METADATA.pb font fields "full_name" and' - ' "post_script_name" have equivalent values.' - ) @check( @@ -627,11 +572,6 @@ def com_google_fonts_check_metadata_match_filename_postscript(font_metadata): f" does not match" f' post_script_name="{font_metadata.post_script_name}".', ) - else: - yield PASS, ( - 'METADATA.pb font fields "filename" and' - ' "post_script_name" have equivalent values.' - ) @check( @@ -654,11 +594,7 @@ def com_google_fonts_check_metadata_valid_full_name_values(font): if familynames == []: yield SKIP, "No TYPOGRAPHIC_FAMILYNAME" - if any((name in font.font_metadata.full_name) for name in familynames): - yield PASS, ( - "METADATA.pb font.full_name field contains font name in right format." - ) - else: + if not any((name in font.font_metadata.full_name) for name in familynames): yield FAIL, Message( "mismatch", f"METADATA.pb font.full_name field" @@ -691,9 +627,6 @@ def com_google_fonts_check_metadata_valid_filename_values(font, family_metadata) for font_metadata in family_metadata.fonts: if font_metadata.filename == expected: passed = True - yield PASS, ( - "METADATA.pb filename field contains font name in right format." - ) break if not passed: @@ -723,11 +656,7 @@ def com_google_fonts_check_metadata_valid_post_script_name_values( "".join(str(font_familyname).split()) for font_familyname in font_familynames ] metadata_psname = "".join(font_metadata.post_script_name.split("-")) - if any(psname in metadata_psname for psname in possible_psnames): - yield PASS, ( - "METADATA.pb postScriptName field contains font name in right format." - ) - else: + if not any(psname in metadata_psname for psname in possible_psnames): yield FAIL, Message( "mismatch", f"METADATA.pb" @@ -761,25 +690,17 @@ def get_name(font, ID): return entry.toUnicode() return "" - if not ("Italic" in style and font.is_variable_font): - yield PASS, ("Not an Italic VF.") - else: - passed = True + if "Italic" in style and font.is_variable_font: if not get_name(ttFont, 25).endswith("Italic"): - passed = False yield FAIL, Message( "nameid25-missing-italic", 'Name ID 25 must end with "Italic" for Italic fonts.', ) if " " in get_name(ttFont, 25): - passed = False yield FAIL, Message( "nameid25-has-spaces", "Name ID 25 must not contain spaces." ) - if passed: - yield PASS, ("Name ID 25 looks good.") - @check( id="com.google.fonts/check/metadata/filenames", @@ -799,14 +720,12 @@ def get_name(font, ID): def com_google_fonts_check_metadata_filenames(fonts, family_directory, family_metadata): """METADATA.pb: Font filenames match font.filename entries?""" - passed = True metadata_filenames = [] font_filenames = [ f for f in os.listdir(family_directory) if f[-4:] in [".ttf", ".otf"] ] for font_metadata in family_metadata.fonts: if font_metadata.filename not in font_filenames: - passed = False yield FAIL, Message( "file-not-found", f'Filename "{font_metadata.filename}" is listed on' @@ -817,14 +736,11 @@ def com_google_fonts_check_metadata_filenames(fonts, family_directory, family_me for font in font_filenames: if font not in metadata_filenames: - passed = False yield FAIL, Message( "file-not-declared", f'Filename "{font}" is not declared' f" on METADATA.pb as a font.filename entry.", ) - if passed: - yield PASS, "Filenames in METADATA.pb look good." @check( @@ -851,8 +767,6 @@ def com_google_fonts_check_metadata_unique_full_name_values(family_metadata): "duplicated", 'Found duplicated "full_name" values in METADATA.pb fonts field.', ) - else: - yield PASS, 'METADATA.pb "fonts" field only has unique "full_name" values.' @check( @@ -878,8 +792,6 @@ def com_google_fonts_check_metadata_unique_weight_style_pairs(family_metadata): "duplicated", "Found duplicated style:weight pair in METADATA.pb fonts field.", ) - else: - yield PASS, 'METADATA.pb "fonts" field only has unique style:weight pairs.' @check( @@ -910,10 +822,6 @@ def com_google_fonts_check_metadata_reserved_font_name(font_metadata): f' contains "Reserved Font Name".' f" This is an error except in a few specific rare cases.", ) - else: - yield PASS, ( - 'METADATA.pb copyright field does not contain "Reserved Font Name".' - ) @check( @@ -961,11 +869,6 @@ def com_google_fonts_check_metadata_nameid_family_and_full_names(ttFont, font_me f' does not match name table entry "{font_familyname}"!' ), ) - else: - yield PASS, ( - "METADATA.pb familyname and fullName fields" - " match corresponding name table entries." - ) @check( @@ -992,8 +895,6 @@ def com_google_fonts_check_metadata_match_name_familyname( f' Family name "{family_metadata.name}" does not match' f' font name: "{font_metadata.name}"', ) - else: - yield PASS, "Font name is the same as family name." @check( @@ -1016,8 +917,6 @@ def com_google_fonts_check_metadata_canonical_weight_value(font_metadata): f" as {font_metadata.weight} which is not a" f" multiple of 100 between 100 and 900.", ) - else: - yield PASS, "Font weight has a canonical value." @check( @@ -1117,11 +1016,6 @@ def com_google_fonts_check_metadata_os2_weightclass(font, font_metadata): f"On METADATA.pb it should be {should_be}," f" but instead got {font_metadata.weight}.\n", ) - else: - yield PASS, ( - "OS/2 usWeightClass or wght axis value matches" - " weight specified at METADATA.pb" - ) @check( @@ -1177,8 +1071,6 @@ def com_google_fonts_check_metadata_match_weight_postscript(font_metadata): ' ended with "{}" or "{}".' "" ).format(font_metadata.post_script_name, pair[0][1], pair[0][0], pair[1][0]) - else: - yield PASS, "Weight value matches postScriptName." @check( @@ -1215,8 +1107,6 @@ def com_google_fonts_check_metadata_canonical_style_names(font, font_metadata): f'The font style is "{font_metadata.style}"' f' but it should be "normal".', ) - else: - yield PASS, "Font styles are named canonically." @check( @@ -1291,8 +1181,6 @@ def clean_url(url): "mismatch", f"Repository URL is {a_url}\n\nBut: {bad_urls}\n", ) - else: - yield PASS, "OK" @check( @@ -1307,7 +1195,6 @@ def clean_url(url): ) def com_google_fonts_check_metadata_primary_script(ttFont, family_metadata): """METADATA.pb: Check for primary_script""" - passed = True def get_primary_script(ttFont): from fontTools import unicodedata @@ -1346,7 +1233,6 @@ def get_sibling_scripts(target): if guessed_primary_script != "Latn": # family_metadata.primary_script is empty but should be set if family_metadata.primary_script in (None, ""): - passed = False message = ( f"METADATA.pb: primary_script field" f" should be '{guessed_primary_script}' but is missing." @@ -1370,7 +1256,6 @@ def get_sibling_scripts(target): ) is None ): - passed = False yield WARN, Message( "wrong-primary-script", ( @@ -1379,9 +1264,6 @@ def get_sibling_scripts(target): ), ) - if passed: - yield PASS, "OK" - @check( id="com.google.fonts/check/metadata/empty_designer", @@ -1402,8 +1284,6 @@ def com_google_fonts_check_metadata_empty_designer(family_metadata): # TODO: Parse AUTHORS.txt and WARN if names do not match # (and then maybe rename the check-id) - else: - yield PASS, "Font designer field is not empty." @check( @@ -1424,8 +1304,6 @@ def com_google_fonts_check_metadata_has_tags(family_metadata): tagged_families = set(row[0] for row in tags[6:]) if family_metadata.name not in tagged_families: yield FATAL, Message("no-tags", "Family does not appear in tag spreadsheet.") - else: - yield PASS, "Family has tags" @check( @@ -1444,7 +1322,6 @@ def com_google_fonts_check_metadata_has_tags(family_metadata): ) def com_google_fonts_check_metadata_escaped_strings(metadata_file): """Ensure METADATA.pb does not use escaped strings.""" - passed = True for line in open(metadata_file, "r", encoding="utf-8").readlines(): # Escaped quotes are fine! # What we're really interested in detecting things like @@ -1457,14 +1334,11 @@ def com_google_fonts_check_metadata_escaped_strings(metadata_file): if len(segments) >= 3: a_string = segments[1] if "\\" in a_string: - passed = False yield FAIL, Message( "escaped-strings", f"Found escaped chars at '{a_string}'." f" Please use an unicode string instead.", ) - if passed: - yield PASS, "OK" @check( @@ -1523,7 +1397,6 @@ def normalize(name): normalized_name += TRANSLATE[c] return normalized_name - passed = True for designer in family_metadata.designer.split(","): designer = designer.strip() normalized_name = normalize(designer) @@ -1545,7 +1418,6 @@ def normalize(name): # f"Config is '{config}'") if response.status_code != requests.codes.OK: - passed = False yield WARN, Message( "profile-not-found", f"It seems that {designer} is still not listed on" @@ -1557,7 +1429,6 @@ def normalize(name): info = get_DesignerInfoProto_Message(response.content) if info.designer != designer.strip(): - passed = False yield FAIL, Message( "mismatch", f"Designer name at METADATA.pb ({designer})" @@ -1566,7 +1437,6 @@ def normalize(name): ) if info.link != "": - passed = False yield FAIL, Message( "link-field", "Currently the link field is not used by the GFonts API." @@ -1575,7 +1445,6 @@ def normalize(name): ) if not info.avatar.file_name and designer != "Google": - passed = False yield FAIL, Message( "missing-avatar", f"Designer {designer} still does not have an avatar image. " @@ -1587,16 +1456,12 @@ def normalize(name): ) response = requests.get(avatar_url, timeout=config.get("timeout")) if response.status_code != requests.codes.OK: - passed = False yield FAIL, Message( "bad-avatar-filename", "The avatar filename provided seems to be incorrect:" f" ({avatar_url})", ) - if passed: - yield PASS, "OK" - @check( id="com.google.fonts/check/metadata/consistent_axis_enumeration", @@ -1613,14 +1478,12 @@ def com_google_fonts_check_metadata_consistent_axis_enumeration( """Validate VF axes match the ones declared on METADATA.pb.""" from fontbakery.utils import pretty_print_list - passed = True md_axes = set(axis.tag for axis in family_metadata.axes) fvar_axes = set(axis.axisTag for axis in ttFont["fvar"].axes) missing = sorted(fvar_axes - md_axes) extra = sorted(md_axes - fvar_axes) if missing: - passed = False yield FAIL, Message( "missing-axes", f"The font variation axes {pretty_print_list(config, missing)}" @@ -1628,14 +1491,11 @@ def com_google_fonts_check_metadata_consistent_axis_enumeration( f" declared on the METADATA.pb file.", ) if extra: - passed = False yield FAIL, Message( "extra-axes", f"The METADATA.pb file lists font variation axes that" f" are not supported but this family: {pretty_print_list(config, extra)}", ) - if passed: - yield PASS, "OK" @check( @@ -1661,8 +1521,6 @@ def com_google_fonts_check_metadata_family_directory_name( f'Directory name is "{dir_name}"\n' f'Expected "{expected}"', ) - else: - yield PASS, f'Directory name is "{dir_name}", as expected.' @check( @@ -1685,7 +1543,6 @@ def com_google_fonts_check_metadata_can_render_samples(ttFont, family_metadata): except ImportError: exit_with_install_instructions("googlefonts") - passed = True languages = LoadLanguages() for lang in family_metadata.languages: if lang not in languages: @@ -1694,7 +1551,6 @@ def com_google_fonts_check_metadata_can_render_samples(ttFont, family_metadata): f"Aparently there's no sample strings for" f" '{lang}' in the gflanguages package.", ) - passed = False continue # Note: checking agains all samples often results in @@ -1715,15 +1571,11 @@ def com_google_fonts_check_metadata_can_render_samples(ttFont, family_metadata): sample_text = sample_text.replace("\n", "").replace("\u200b", "") if not can_shape(ttFont, sample_text): - passed = False yield FAIL, Message( "sample-text", f'Font can\'t render "{lang}" sample text:\n' f'"{sample_text}"\n', ) - if passed: - yield PASS, "OK." - @check( id="com.google.fonts/check/metadata/category_hints", @@ -1762,8 +1614,6 @@ def com_google_fonts_check_metadata_category_hint(family_metadata): f'Familyname seems to hint at "{inferred_category}" but' f' METADATA.pb declares it as "{family_metadata.category}".', ) - else: - yield PASS, "OK." @check( @@ -1813,5 +1663,3 @@ def clean_url(url): f"From '{minisite_url}'\n\n" f"To: '{expected}'\n\n", ) - else: - yield PASS, "OK" From a3d18b2d5304a6b3f25e119337c85f7de4b6e271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 01:52:04 -0300 Subject: [PATCH 21/46] simplify PASS results - googlefonts profile (name) (issue #4612) --- Lib/fontbakery/checks/googlefonts/name.py | 76 ++++------------------- 1 file changed, 12 insertions(+), 64 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/name.py b/Lib/fontbakery/checks/googlefonts/name.py index ec8fa67555..2557afb9aa 100644 --- a/Lib/fontbakery/checks/googlefonts/name.py +++ b/Lib/fontbakery/checks/googlefonts/name.py @@ -20,7 +20,6 @@ def com_google_fonts_check_name_unwanted_chars(ttFont): """Substitute copyright, registered and trademark symbols in name table entries.""" - passed = True replacement_map = [("\u00a9", "(c)"), ("\u00ae", "(r)"), ("\u2122", "(tm)")] for name in ttFont["name"].names: string = str(name.string, encoding=name.getEncoding()) @@ -32,12 +31,6 @@ def com_google_fonts_check_name_unwanted_chars(ttFont): f"NAMEID #{name.nameID} contains symbols that" f" should be replaced by '{ascii_repl}'.", ) - passed = False - if passed: - yield PASS, ( - "No need to substitute copyright, registered and" - " trademark symbols in name table entries of this font." - ) @check( @@ -56,28 +49,22 @@ def com_google_fonts_check_name_unwanted_chars(ttFont): ) def com_google_fonts_check_name_description_max_length(ttFont): """Description strings in the name table must not exceed 200 characters.""" - passed = True for name in ttFont["name"].names: if ( name.nameID == NameID.DESCRIPTION and len(name.string.decode(name.getEncoding())) > 200 ): - passed = False - break - - if passed: - yield PASS, "All description name records have reasonably small lengths." - else: - yield WARN, Message( - "too-long", - f"A few name table entries with ID={NameID.DESCRIPTION}" - f" (NameID.DESCRIPTION) are longer than 200 characters." - f" Please check whether those entries are copyright" - f" notices mistakenly stored in the description" - f" string entries by a bug in an old FontLab version." - f" If that's the case, then such copyright notices" - f" must be removed from these entries.", - ) + yield WARN, Message( + "too-long", + f"A few name table entries with ID={NameID.DESCRIPTION}" + f" (NameID.DESCRIPTION) are longer than 200 characters." + f" Please check whether those entries are copyright" + f" notices mistakenly stored in the description" + f" string entries by a bug in an old FontLab version." + f" If that's the case, then such copyright notices" + f" must be removed from these entries.", + ) + return @check( @@ -97,10 +84,8 @@ def com_google_fonts_check_name_version_format(ttFont): def is_valid_version_format(value): return re.match(r"Version\s0*[1-9][0-9]*\.\d+", value) - passed = True version_entries = get_name_entry_strings(ttFont, NameID.VERSION_STRING) if len(version_entries) == 0: - passed = False yield FAIL, Message( "no-version-string", f"Font lacks a NameID.VERSION_STRING" @@ -108,7 +93,6 @@ def is_valid_version_format(value): ) for ventry in version_entries: if not is_valid_version_format(ventry): - passed = False yield FAIL, Message( "bad-version-strings", f"The NameID.VERSION_STRING" @@ -117,8 +101,6 @@ def is_valid_version_format(value): f" greater than or equal to 1.000." f' Current version string is: "{ventry}"', ) - if passed: - yield PASS, "Version format in NAME table entries is correct." @check( @@ -133,7 +115,6 @@ def com_google_fonts_check_name_familyname_first_char(ttFont): """Make sure family name does not begin with a digit.""" from fontbakery.utils import get_name_entry_strings - passed = True for familyname in get_name_entry_strings(ttFont, NameID.FONT_FAMILY_NAME): digits = map(str, range(0, 10)) if familyname[0] in digits: @@ -141,9 +122,6 @@ def com_google_fonts_check_name_familyname_first_char(ttFont): "begins-with-digit", f"Font family name '{familyname}' begins with a digit!", ) - passed = False - if passed: - yield PASS, "Font family name first character is not a digit." @check( @@ -192,11 +170,6 @@ def com_google_fonts_check_name_ascii_only_entries(ttFont): " NAME table entries." ), ) - else: - yield PASS, ( - "None of the ASCII-only NAME table entries" - " contain non-ASCII characteres." - ) @check( @@ -281,8 +254,6 @@ def style_names(nametable): if not passed: yield FAIL, Message("bad-names", f"Font names are incorrect:\n\n{md_table}") - else: - yield PASS, f"Font names are good:\n\n{md_table}" @check( @@ -311,17 +282,14 @@ def com_google_fonts_check_name_mandatory_entries(ttFont, style): NameID.TYPOGRAPHIC_FAMILY_NAME, NameID.TYPOGRAPHIC_SUBFAMILY_NAME, ] - passed = True + # The font must have at least these name IDs: for nameId in required_nameIDs: if len(get_name_entry_strings(ttFont, nameId)) == 0: - passed = False yield FAIL, Message( "missing-entry", f"Font lacks entry with nameId={nameId}" f" ({NameID(nameId).name})", ) - if passed: - yield PASS, "Font contains values for all mandatory name table entries." @check( @@ -342,8 +310,6 @@ def com_google_fonts_check_name_family_and_style_max_length(ttFont): ribbi_re = " (" + "|".join(RIBBI_STYLE_NAMES) + ")$" - passed = True - def strip_ribbi(x): return re.sub(ribbi_re, "", x) @@ -371,7 +337,6 @@ def strip_ribbi(x): for the_name in get_name_entry_strings(ttFont, nameid): the_name = transform(the_name) if len(the_name) > maxlen: - passed = False yield loglevel, Message( f"nameid{nameid}-too-long", f"Name ID {nameid} '{the_name}' exceeds" @@ -401,9 +366,6 @@ def strip_ribbi(x): f" accented letters in Microsoft Word on Windows 10 and 11.", ) - if passed: - yield PASS, "All name entries are good." - @disable @check( @@ -430,8 +392,6 @@ def com_google_fonts_check_glyphs_file_name_family_and_style_max_length(glyphsFi f" in order to understand the reasoning behind these" f" name table records max-length criteria.", ) - else: - yield PASS, "ok" @check( @@ -450,19 +410,15 @@ def com_google_fonts_check_glyphs_file_name_family_and_style_max_length(glyphsFi ) def com_google_fonts_check_name_line_breaks(ttFont): """Name table entries should not contain line-breaks.""" - passed = True for name in ttFont["name"].names: string = name.string.decode(name.getEncoding()) if "\n" in string: - passed = False yield FAIL, Message( "line-break", f"Name entry {NameID(name.nameID).name}" f" on platform {PlatformID(name.platformID).name}" f" contains a line-break.", ) - if passed: - yield PASS, "Name table entries are all single-line (no line-breaks found)." @check( @@ -495,7 +451,6 @@ def com_google_fonts_check_name_family_name_compliance(ttFont): abbreviations_exceptions_txt = ( "data/googlefonts/abbreviations_familyname_exceptions.txt" ) - passed = True if get_name_entries(ttFont, NameID.TYPOGRAPHIC_FAMILY_NAME): family_name = get_name_entries(ttFont, NameID.TYPOGRAPHIC_FAMILY_NAME)[ @@ -523,7 +478,6 @@ def com_google_fonts_check_name_family_name_compliance(ttFont): break if not known_exception: - passed = False yield FAIL, Message( "camelcase", f'"{family_name}" is a CamelCased name.' @@ -552,7 +506,6 @@ def com_google_fonts_check_name_family_name_compliance(ttFont): if not known_exception: # Allow SC ending if not family_name.endswith("SC"): - passed = False yield FAIL, Message( "abbreviation", f'"{family_name}" contains an abbreviation.' ) @@ -561,7 +514,6 @@ def com_google_fonts_check_name_family_name_compliance(ttFont): forbidden_characters = re.findall(r"[^a-zA-Z0-9 ]", family_name) if forbidden_characters: forbidden_characters = "".join(sorted(list(set(forbidden_characters)))) - passed = False yield FAIL, Message( "forbidden-characters", f'"{family_name}" contains the following characters' @@ -570,11 +522,7 @@ def com_google_fonts_check_name_family_name_compliance(ttFont): # Starts with uppercase if not bool(re.match(r"^[A-Z]", family_name)): - passed = False yield FAIL, Message( "starts-with-not-uppercase", f'"{family_name}" doesn\'t start with an uppercase letter.', ) - - if passed: - yield PASS, "Font name looks good." From c9d80a104fe236ceea3a6d92f1a47caabb066c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 01:57:49 -0300 Subject: [PATCH 22/46] simplify PASS results - googlefonts profile (os2) (issue #4612) --- Lib/fontbakery/checks/googlefonts/os2.py | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/os2.py b/Lib/fontbakery/checks/googlefonts/os2.py index 677b1af85d..974b5ddcd3 100644 --- a/Lib/fontbakery/checks/googlefonts/os2.py +++ b/Lib/fontbakery/checks/googlefonts/os2.py @@ -2,7 +2,7 @@ import re from fontbakery.checks.googlefonts.conditions import expected_font_names -from fontbakery.prelude import check, Message, WARN, PASS, FAIL, SKIP +from fontbakery.prelude import check, Message, WARN, FAIL, SKIP from fontbakery.utils import exit_with_install_instructions @@ -119,8 +119,6 @@ def com_google_fonts_check_vendor_id(ttFont): f"OS/2 VendorID value '{vid}' is not yet recognized." f" {SUGGEST_MICROSOFT_VENDORLIST_WEBSITE}", ) - else: - yield PASS, f"OS/2 VendorID '{vid}' looks good!" @check( @@ -163,8 +161,6 @@ def com_google_fonts_check_os2_fsselectionbit7(fonts): f"OS/2.fsSelection bit 7 (USE_TYPO_METRICS) was" f"NOT set in the following fonts: {bad_fonts}.", ) - else: - yield PASS, "OK" @check( @@ -225,8 +221,6 @@ def com_google_fonts_check_fstype(ttFont): f" Google Fonts collection, so the fsType field" f" must be set to zero (Installable Embedding) instead.", ) - else: - yield PASS, "OS/2 fsType is properly set to zero." @check( @@ -253,7 +247,6 @@ def com_google_fonts_check_usweightclass(font, ttFonts): """ Check the OS/2 usWeightClass is appropriate for the font's best SubFamily name. """ - passed = True value = font.ttFont["OS/2"].usWeightClass expected_names = expected_font_names(font.ttFont, ttFonts) expected_value = expected_names["OS/2"].usWeightClass @@ -264,7 +257,6 @@ def com_google_fonts_check_usweightclass(font, ttFonts): ) if font.is_variable_font: if not has_expected_value: - passed = False yield FAIL, Message( "bad-value", fail_message.format(style_name, expected_value, value) ) @@ -275,33 +267,25 @@ def com_google_fonts_check_usweightclass(font, ttFonts): # for static otfs, Thin must be 250 and ExtraLight must be 275 elif "Thin" in style_name: if font.is_ttf and value not in [100, 250]: - passed = False yield FAIL, Message( "bad-value", fail_message.format(style_name, expected_value, value) ) if font.is_cff and value != 250: - passed = False yield FAIL, Message( "bad-value", fail_message.format(style_name, 250, value) ) elif "ExtraLight" in style_name: if font.is_ttf and value not in [200, 275]: - passed = False yield FAIL, Message( "bad-value", fail_message.format(style_name, expected_value, value) ) if font.is_cff and value != 275: - passed = False yield FAIL, Message( "bad-value", fail_message.format(style_name, 275, value) ) elif not has_expected_value: - passed = False yield FAIL, Message( "bad-value", fail_message.format(style_name, expected_value, value) ) - - if passed: - yield PASS, "OS/2 usWeightClass is good" From 39bee3f634e172e29cc14cdeb8c0e74fd2a3065b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 02:00:42 -0300 Subject: [PATCH 23/46] simplify PASS results - googlefonts profile (repo) (issue #4612) --- Lib/fontbakery/checks/googlefonts/repo.py | 23 ++++++----------------- tests/checks/googlefonts_test.py | 3 +-- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/repo.py b/Lib/fontbakery/checks/googlefonts/repo.py index 9ff9a9caf5..bed5bc5335 100644 --- a/Lib/fontbakery/checks/googlefonts/repo.py +++ b/Lib/fontbakery/checks/googlefonts/repo.py @@ -2,7 +2,7 @@ from fontbakery.constants import NameID from fontbakery.testable import Font -from fontbakery.prelude import check, Message, PASS, FAIL, WARN, SKIP +from fontbakery.prelude import check, Message, FAIL, WARN, SKIP from fontbakery.utils import bullet_list @@ -26,9 +26,7 @@ def com_google_fonts_check_repo_fb_report(family_directory): if '"result"' in open(f, encoding="utf-8").read() ] ) - if not has_report_files: - yield PASS, "OK" - else: + if has_report_files: yield WARN, Message( "fb-report", "There's no need to keep a copy of FontBakery reports in the" @@ -60,8 +58,6 @@ def com_google_fonts_check_repo_upstream_yaml_has_required_fields(upstream_yaml) f"The upstream.yaml file is missing the following fields:" f" {list(missing_fields)}", ) - else: - yield PASS, "The upstream.yaml file contains all necessary fields" @check( @@ -86,9 +82,7 @@ def com_google_fonts_check_repo_zip_files(family_directory, config): for ext in COMMON_ZIP_EXTENSIONS: zip_files.extend(filenames_ending_in(ext, family_directory)) - if not zip_files: - yield PASS, "OK" - else: + if zip_files: files_list = pretty_print_list(config, zip_files, sep="\n\t* ") yield FAIL, Message( "zip-files", @@ -146,9 +140,7 @@ def com_google_fonts_check_repo_sample_image(readme_contents, readme_directory, f" {os.path.join(readme_directory, image_path)}\n", ) else: - if line_number < 10: - yield PASS, "Looks good!" - else: + if line_number >= 10: yield WARN, Message( "not-ideal-placement", "Please consider placing the sample image closer" @@ -206,7 +198,7 @@ def manually_hinted(font): if f.endswith(".ttf") ] if not static_fonts: - yield PASS, "OK" + # it is all fine! return if not all(manually_hinted(font) for font in static_fonts): @@ -216,7 +208,6 @@ def manually_hinted(font): "manually hinted. Delete the directory.", ) return - yield PASS, "OK" @check( @@ -259,9 +250,7 @@ def com_google_fonts_check_repo_dirname_match_nameid_1(fonts): expected = "".join(expected.split("-")) _, familypath, _ = os.path.abspath(regular.file).split(os.path.sep)[-3:] - if familypath == expected: - yield PASS, "OK" - else: + if familypath != expected: yield FAIL, Message( "mismatch", f"Family name on the name table ('{entry}') does not match" diff --git a/tests/checks/googlefonts_test.py b/tests/checks/googlefonts_test.py index c6fe4ac232..3bf1b9a7eb 100644 --- a/tests/checks/googlefonts_test.py +++ b/tests/checks/googlefonts_test.py @@ -3281,8 +3281,7 @@ def test_check_repo_dirname_match_nameid_1(tmp_path): # PASS result fonts = [str(pth) for pth in tmp_gf_dir.glob("*.ttf")] - msg = assert_PASS(check(fonts)) - assert msg == "OK" + assert_PASS(check(fonts)) # Get the path of the Regular font; it will be used for deleting the file later. reg_font_path = next((pth for pth in fonts if "Regular" in pth), None) From 48f7c8990ebea71c7531e103388b0c30ce29830f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 02:02:06 -0300 Subject: [PATCH 24/46] simplify PASS results - googlefonts profile (subsets) (issue #4612) --- Lib/fontbakery/checks/googlefonts/subsets.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/subsets.py b/Lib/fontbakery/checks/googlefonts/subsets.py index 7977ff3823..c9e64e3a3c 100644 --- a/Lib/fontbakery/checks/googlefonts/subsets.py +++ b/Lib/fontbakery/checks/googlefonts/subsets.py @@ -1,6 +1,6 @@ from collections import defaultdict -from fontbakery.prelude import FAIL, PASS, WARN, Message, check +from fontbakery.prelude import FAIL, WARN, Message, check from fontbakery.utils import exit_with_install_instructions @@ -26,7 +26,6 @@ def com_google_fonts_check_metadata_unsupported_subsets( except ImportError: exit_with_install_instructions("googlefonts") - passed = True for subset in family_metadata.subsets: if subset == "menu": continue @@ -44,14 +43,11 @@ def com_google_fonts_check_metadata_unsupported_subsets( subset_codepoints -= set([0, 13, 32, 160]) if len(subset_codepoints.intersection(font_codepoints)) == 0: - passed = False yield FAIL, Message( "unsupported-subset", f"Please remove '{subset}' from METADATA.pb since none" f" of its glyphs are supported by this font file.", ) - if passed: - yield PASS, "OK" @check( @@ -101,7 +97,7 @@ def com_google_fonts_check_metadata_unreachable_subsetting(font, config): font_codepoints = font_codepoints - set(CodepointsInSubset(subset)) if not font_codepoints: - yield PASS, "OK" + # it is all fine! return unreachable = [] From bde458b752bbfbecba39249c37a7fa5aea902b94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 02:02:45 -0300 Subject: [PATCH 25/46] simplify PASS results - googlefonts profile (tables) (issue #4612) --- Lib/fontbakery/checks/googlefonts/tables.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/tables.py b/Lib/fontbakery/checks/googlefonts/tables.py index 5d4cb824b5..5b22fc5e8b 100644 --- a/Lib/fontbakery/checks/googlefonts/tables.py +++ b/Lib/fontbakery/checks/googlefonts/tables.py @@ -1,4 +1,4 @@ -from fontbakery.prelude import check, Message, WARN, PASS, FAIL +from fontbakery.prelude import check, Message, WARN, FAIL @check( @@ -55,8 +55,6 @@ def com_google_fonts_check_aat(ttFont): f" they built with:\n\n" f" {unwanted_list}", ) - else: - yield PASS, "There are no unwanted AAT tables." @check( @@ -81,5 +79,3 @@ def com_google_fonts_check_no_debugging_tables(ttFont): f"This font file contains the following" f" pre-production tables: {tables_list}", ) - else: - yield PASS, "OK" From cee656990bf65e470569697a0e9db8cca57524e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 02:08:47 -0300 Subject: [PATCH 26/46] simplify PASS results - googlefonts profile (varfont) (issue #4612) --- Lib/fontbakery/checks/googlefonts/varfont.py | 46 +------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/varfont.py b/Lib/fontbakery/checks/googlefonts/varfont.py index 289d102f20..1e15ac3acb 100644 --- a/Lib/fontbakery/checks/googlefonts/varfont.py +++ b/Lib/fontbakery/checks/googlefonts/varfont.py @@ -105,21 +105,16 @@ def stat_axis_values(ttFont): table.sort(key=lambda k: (k["Axis"], str(k["Expected Value"]))) md_table = markdown_table(table) - passed = True is_italic = any(a.axisTag in ["ital", "slnt"] for a in ttFont["fvar"].axes) missing_ital_av = any("Italic" in r["Name"] for r in table) if is_italic and missing_ital_av: - passed = False yield FAIL, Message("missing-ital-axis-values", "Italic Axis Value missing.") if font_axis_values != expected_axis_values: - passed = False yield FAIL, Message( "bad-axis-values", f"Compulsory STAT Axis Values are incorrect:\n\n {md_table}\n", ) - if passed: - yield PASS, "Compulsory STAT Axis Values are correct." @check( @@ -196,8 +191,6 @@ def get_instances(ttFont): " defaults. This may be intentional so please check with the font author:" f"\n\n{md_table}", ) - else: - yield PASS, f"fvar instances are good:\n\n{md_table}" @check( @@ -212,7 +205,6 @@ def get_instances(ttFont): def com_google_fonts_check_fvar_name_entries(ttFont): """All name entries referenced by fvar instances exist on the name table?""" - passed = True for instance in ttFont["fvar"].instances: entries = [ entry @@ -220,7 +212,6 @@ def com_google_fonts_check_fvar_name_entries(ttFont): if entry.nameID == instance.subfamilyNameID ] if len(entries) == 0: - passed = False yield FAIL, Message( "missing-name", f"Named instance with coordinates {instance.coordinates}" @@ -228,9 +219,6 @@ def com_google_fonts_check_fvar_name_entries(ttFont): f" (nameID={instance.subfamilyNameID}).", ) - if passed: - yield PASS, "OK" - @check( id="com.google.fonts/check/varfont/consistent_axes", @@ -251,11 +239,9 @@ def com_google_fonts_check_varfont_consistent_axes(VFs): {k.axisTag: (k.minValue, k.maxValue) for k in vf["fvar"].axes} ) - passed = True for vf in VFs: for axis in ref_ranges: if axis not in map(lambda x: x.axisTag, vf["fvar"].axes): - passed = False yield FAIL, Message( "missing-axis", f"{os.path.basename(vf.reader.file.name)}:" @@ -276,15 +262,11 @@ def com_google_fonts_check_varfont_consistent_axes(VFs): for axis, ranges in expected_ranges: if len(ranges) > 1: - passed = False yield FAIL, Message( "inconsistent-axis-range", "Axis 'axis' has diverging ranges accross the family: {ranges}.", ) - if passed: - yield PASS, "All looks good!" - @check( id="com.google.fonts/check/varfont/generate_static", @@ -353,9 +335,7 @@ def com_google_fonts_check_varfont_generate_static(ttFont): ) def com_google_fonts_check_varfont_has_HVAR(ttFont): """Check that variable fonts have an HVAR table.""" - if "HVAR" in ttFont.keys(): - yield PASS, ("This variable font contains an HVAR table.") - else: + if "HVAR" not in ttFont.keys(): yield FAIL, Message( "lacks-HVAR", "All variable fonts on the Google Fonts collection" @@ -446,7 +426,6 @@ def com_google_fonts_check_varfont_duplexed_axis_reflow(font, ttFont, config): # Determine if any kerning rules vary the horizontal advance. # This is going to get grubby. - bad_kerning = False if "GDEF" in ttFont and hasattr(ttFont["GDEF"].table, "VarStore"): effective_regions = set() @@ -485,16 +464,8 @@ def com_google_fonts_check_varfont_duplexed_axis_reflow(font, ttFont, config): f" ({relevant_axes_display})" f" (e.g. {left}/{right})", ) - bad_kerning = True break - # Check kerning here - if not bad_glyphs_by_axis and not bad_kerning: - yield PASS, ( - "No variations or kern rules vary horizontal advance along " - "any duplexed axes" - ) - @check( id="com.google.fonts/check/varfont_duplicate_instance_names", @@ -515,7 +486,6 @@ def com_google_fonts_check_varfont_duplicate_instance_names(ttFont): """Check variable font instances don't have duplicate names""" seen = set() duplicate = set() - found_all_eng_name_recs = True PLAT_ID = PlatformID.WINDOWS ENC_ID = WindowsEncodingID.UNICODE_BMP LANG_ID = WindowsLanguageID.ENGLISH_USA @@ -532,7 +502,6 @@ def com_google_fonts_check_varfont_duplicate_instance_names(ttFont): else: seen.add(name) else: - found_all_eng_name_recs = False yield FAIL, Message( "name-record-not-found", f"A 'name' table record for platformID {PLAT_ID}," @@ -547,9 +516,6 @@ def com_google_fonts_check_varfont_duplicate_instance_names(ttFont): "Following instances names are duplicate:\n\n" f"{duplicate_instances}", ) - elif found_all_eng_name_recs: - yield PASS, "Instance names are unique" - @check( id="com.google.fonts/check/varfont/unsupported_axes", @@ -572,8 +538,6 @@ def com_google_fonts_check_varfont_unsupported_axes(font): "unsupported-ital", 'The "ital" axis is not yet well supported on Google Chrome.', ) - else: - yield PASS, "Looks good!" @check( @@ -601,8 +565,6 @@ def com_google_fonts_check_mandatory_avar_table(ttFont): yield WARN, Message( "missing-avar", "This variable font does not have an avar table." ) - else: - yield PASS, "OK" @condition(Font) @@ -668,8 +630,6 @@ def x_delta(slant): " which is likely a mistake. It needs to be negative" " to lean rightwards.", ) - else: - yield PASS, "Angle of 'slnt' axis looks good." @check( @@ -690,7 +650,6 @@ def com_google_fonts_check_varfont_instances_in_order(ttFont, config): from fontbakery.utils import bullet_list coords = [i.coordinates for i in ttFont["fvar"].instances] - ok = True # Partition into sub-lists based on the other axes values. # e.g. "Thin Regular", "Bold Regular", "Thin Condensed", "Bold Condensed" # becomes [ ["Thin Regular", "Bold Regular"], ["Thin Condensed", "Bold Condensed"] ] @@ -711,6 +670,3 @@ def com_google_fonts_check_varfont_instances_in_order(ttFont, config): "The fvar table instances are not in ascending order of weight:\n" + bullet_list(config, lst), ) - ok = False - if ok: - yield PASS, "Instances are in order of weight." From 4a4db73e6b32cc32fe7263284fcd19e91bc10a8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 02:11:14 -0300 Subject: [PATCH 27/46] simplify PASS results - googlefonts profile (vmetrics) (issue #4612) --- Lib/fontbakery/checks/googlefonts/vmetrics.py | 40 +------------------ 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/Lib/fontbakery/checks/googlefonts/vmetrics.py b/Lib/fontbakery/checks/googlefonts/vmetrics.py index 569f0d2c04..1d9d084c75 100644 --- a/Lib/fontbakery/checks/googlefonts/vmetrics.py +++ b/Lib/fontbakery/checks/googlefonts/vmetrics.py @@ -1,6 +1,6 @@ import os -from fontbakery.prelude import check, Message, PASS, FAIL, WARN +from fontbakery.prelude import check, Message, FAIL, WARN from fontbakery.constants import ( NameID, PlatformID, @@ -67,12 +67,9 @@ def com_google_fonts_check_vertical_metrics(ttFont): "hhea.lineGap": 0, } - passed = True - # Check typo metrics and hhea lineGap match our expected values for k in expected_metrics: if font_metrics[k] != expected_metrics[k]: - passed = False yield FAIL, Message( f"bad-{k}", f'{k} is "{font_metrics[k]}" it should' f" be {expected_metrics[k]}", @@ -87,7 +84,6 @@ def com_google_fonts_check_vertical_metrics(ttFont): # Check the sum of the hhea metrics is not below 1.2 # (120% of upm or 1200 units for 1000 upm font) if hhea_sum < 1.2: - passed = False yield FAIL, Message( "bad-hhea-range", f"The sum of hhea.ascender + abs(hhea.descender) + hhea.lineGap" @@ -97,7 +93,6 @@ def com_google_fonts_check_vertical_metrics(ttFont): # Check the sum of the hhea metrics is below 2.0 elif hhea_sum > 2.0: - passed = False yield FAIL, Message( "bad-hhea-range", f"The sum of hhea.ascender + abs(hhea.descender) + hhea.lineGap" @@ -107,7 +102,6 @@ def com_google_fonts_check_vertical_metrics(ttFont): # Check the sum of the hhea metrics is between 1.1-1.5x of the font's upm elif hhea_sum > 1.5: - passed = False yield WARN, Message( "bad-hhea-range", f"We recommend the absolute sum of the hhea metrics should be" @@ -117,7 +111,6 @@ def com_google_fonts_check_vertical_metrics(ttFont): # OS/2.sTypoAscender must be strictly positive if font_metrics["OS/2.sTypoAscender"] < 0: - passed = False yield FAIL, Message( "typo-ascender", "The OS/2 sTypoAscender must be strictly positive," @@ -126,7 +119,6 @@ def com_google_fonts_check_vertical_metrics(ttFont): # hhea.ascent must be strictly positive if font_metrics["hhea.ascent"] <= 0: - passed = False yield FAIL, Message( "hhea-ascent", "The hhea ascender must be strictly positive," @@ -135,7 +127,6 @@ def com_google_fonts_check_vertical_metrics(ttFont): # OS/2.usWinAscent must be strictly positive if font_metrics["OS/2.usWinAscent"] <= 0: - passed = False yield FAIL, Message( "win-ascent", f"The OS/2.usWinAscent must be strictly positive," @@ -144,7 +135,6 @@ def com_google_fonts_check_vertical_metrics(ttFont): # OS/2.sTypoDescender must be negative or zero if font_metrics["OS/2.sTypoDescender"] > 0: - passed = False yield FAIL, Message( "typo-descender", "The OS/2 sTypoDescender must be negative or zero." @@ -153,7 +143,6 @@ def com_google_fonts_check_vertical_metrics(ttFont): # hhea.descent must be negative or zero if font_metrics["hhea.descent"] > 0: - passed = False yield FAIL, Message( "hhea-descent", "The hhea descender must be negative or zero." @@ -162,16 +151,12 @@ def com_google_fonts_check_vertical_metrics(ttFont): # OS/2.usWinDescent must be positive or zero if font_metrics["OS/2.usWinDescent"] < 0: - passed = False yield FAIL, Message( "win-descent", "The OS/2.usWinDescent must be positive or zero." " This font has a negative value.", ) - if passed: - yield PASS, "Vertical metrics are good" - @check( id="com.google.fonts/check/vertical_metrics_regressions", @@ -224,10 +209,8 @@ def com_google_fonts_check_vertical_metrics_regressions(regular_ttFont, font): gf_has_typo_metrics = typo_metrics_enabled(gf_ttFont) ttFont_has_typo_metrics = typo_metrics_enabled(ttFont) - passed = True if gf_has_typo_metrics: if not ttFont_has_typo_metrics: - passed = False yield FAIL, Message( "bad-fsselection-bit7", "fsSelection bit 7 needs to be enabled because " @@ -248,7 +231,6 @@ def com_google_fonts_check_vertical_metrics_regressions(regular_ttFont, font): math.ceil(ttFont["OS/2"].usWinDescent), ): if not ttFont_has_typo_metrics: - passed = False yield FAIL, Message( "bad-fsselection-bit7", "fsSelection bit 7 needs to be enabled " @@ -275,7 +257,6 @@ def com_google_fonts_check_vertical_metrics_regressions(regular_ttFont, font): hhea_descender = ttFont["hhea"].descent if typo_ascender != expected_ascender: - passed = False yield FAIL, Message( "bad-typo-ascender", f"{full_font_name}:" @@ -284,7 +265,6 @@ def com_google_fonts_check_vertical_metrics_regressions(regular_ttFont, font): ) if typo_descender != expected_descender: - passed = False yield FAIL, Message( "bad-typo-descender", f"{full_font_name}:" @@ -293,7 +273,6 @@ def com_google_fonts_check_vertical_metrics_regressions(regular_ttFont, font): ) if hhea_ascender != expected_ascender: - passed = False yield FAIL, Message( "bad-hhea-ascender", f"{full_font_name}:" @@ -302,15 +281,12 @@ def com_google_fonts_check_vertical_metrics_regressions(regular_ttFont, font): ) if hhea_descender != expected_descender: - passed = False yield FAIL, Message( "bad-hhea-descender", f"{full_font_name}:" f" hhea Descender is {hhea_descender}" f" when it should be {expected_descender}", ) - if passed: - yield PASS, "Vertical metrics have not regressed." @check( @@ -360,11 +336,8 @@ def com_google_fonts_check_cjk_vertical_metrics(ttFont): "hhea.lineGap": 0, } - passed = True - # Check fsSelection bit 7 is not enabled if typo_metrics_enabled(ttFont): - passed = False yield FAIL, Message( "bad-fselection-bit7", "OS/2 fsSelection bit 7 must be disabled" ) @@ -372,7 +345,6 @@ def com_google_fonts_check_cjk_vertical_metrics(ttFont): # Check typo metrics and hhea lineGap match our expected values for k in expected_metrics: if font_metrics[k] != expected_metrics[k]: - passed = False yield FAIL, Message( f"bad-{k}", f'{k} is "{font_metrics[k]}" it should be {expected_metrics[k]}', @@ -380,13 +352,11 @@ def com_google_fonts_check_cjk_vertical_metrics(ttFont): # Check hhea and win values match if font_metrics["hhea.ascent"] != font_metrics["OS/2.usWinAscent"]: - passed = False yield FAIL, Message( "ascent-mismatch", "hhea.ascent must match OS/2.usWinAscent" ) if abs(font_metrics["hhea.descent"]) != font_metrics["OS/2.usWinDescent"]: - passed = False yield FAIL, Message( "descent-mismatch", "hhea.descent must match absolute value of OS/2.usWinDescent", @@ -399,16 +369,12 @@ def com_google_fonts_check_cjk_vertical_metrics(ttFont): + font_metrics["hhea.lineGap"] ) / font_upm if not 1.1 < hhea_sum <= 1.5: - passed = False yield WARN, Message( "bad-hhea-range", f"We recommend the absolute sum of the hhea metrics should be" f" between 1.1-1.4x of the font's upm. This font has {hhea_sum}x", ) - if passed: - yield PASS, "Vertical metrics are good" - @check( id="com.google.fonts/check/cjk_vertical_metrics_regressions", @@ -444,7 +410,6 @@ def com_google_fonts_check_cjk_vertical_metrics_regressions( upm_scale = ttFont["head"].unitsPerEm / gf_ttFont["head"].unitsPerEm - passed = True for tbl, attrib in [ ("OS/2", "sTypoAscender"), ("OS/2", "sTypoDescender"), @@ -458,10 +423,7 @@ def com_google_fonts_check_cjk_vertical_metrics_regressions( gf_val = math.ceil(getattr(gf_ttFont[tbl], attrib) * upm_scale) f_val = math.ceil(getattr(ttFont[tbl], attrib)) if gf_val != f_val: - passed = False yield FAIL, Message( "cjk-metric-regression", f" {tbl} {attrib} is {f_val}" f" when it should be {gf_val}", ) - if passed: - yield PASS, "CJK vertical metrics are good" From a848d3011a1c1cea3c57b896a77c84ad98847583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 02:31:40 -0300 Subject: [PATCH 28/46] simplify PASS results - iso15008 profile (issue #4612) --- Lib/fontbakery/checks/iso15008.py | 32 ++++++++----------------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/Lib/fontbakery/checks/iso15008.py b/Lib/fontbakery/checks/iso15008.py index 75d89f9e0c..fcb60b3704 100644 --- a/Lib/fontbakery/checks/iso15008.py +++ b/Lib/fontbakery/checks/iso15008.py @@ -6,7 +6,7 @@ from beziers.point import Point from fontTools.pens.boundsPen import BoundsPen -from fontbakery.prelude import check, PASS, FAIL, Message +from fontbakery.prelude import check, FAIL, Message from fontbakery.utils import exit_with_install_instructions DISCLAIMER = """ @@ -105,9 +105,7 @@ def com_google_fonts_check_iso15008_proportions(ttFont): glyphset["H"].draw(pen) (xMin, yMin, xMax, yMax) = pen.bounds proportion = (xMax - xMin) / (yMax - yMin) - if 0.65 <= proportion <= 0.80: - yield PASS, "the letter H is not too narrow or too wide" - else: + if not 0.65 <= proportion <= 0.80: yield FAIL, Message( "invalid-proportion", f"The proportion of H width to H height ({proportion})" @@ -139,9 +137,7 @@ def com_google_fonts_check_iso15008_stem_width(ttFont): return ascender = ttFont["hhea"].ascender proportion = width / ascender - if 0.10 <= proportion <= 0.20: - yield PASS, "the stem width is not too light or too bold" - else: + if not 0.10 <= proportion <= 0.20: yield FAIL, Message( "invalid-proportion", f"The proportion of stem width to ascender ({proportion})" @@ -194,9 +190,7 @@ def com_google_fonts_check_iso15008_intercharacter_spacing(font, ttFont): "There was no 'l' glyph in the font, so the spacing could not be tested", ) return - if 1.5 <= (l_l / width) <= 2.4: - yield PASS, "Distance between vertical strokes was adequate" - else: + if not 1.5 <= (l_l / width) <= 2.4: yield FAIL, Message( "bad-vertical-vertical-spacing", f"The space between vertical strokes ({l_l})" @@ -223,9 +217,7 @@ def com_google_fonts_check_iso15008_intercharacter_spacing(font, ttFont): ) return - if (l_v / width) > 0.85: - yield PASS, "Distance between vertical and diagonal strokes was adequate" - else: + if (l_v / width) <= 0.85: yield FAIL, Message( "bad-vertical-diagonal-spacing", f"The space between vertical and diagonal strokes ({l_v})" @@ -233,10 +225,7 @@ def com_google_fonts_check_iso15008_intercharacter_spacing(font, ttFont): f" value of {width * 0.85}", ) - v_v = v_rsb + pair_kerning(font, "v", "v") + v_lsb - if v_v > 0: - yield PASS, "Distance between diagonal strokes was adequate" - else: + if v_rsb + pair_kerning(font, "v", "v") + v_lsb <= 0: yield FAIL, Message( "bad-diagonal-diagonal-spacing", "Diagonal strokes (vv) were touching" ) @@ -286,9 +275,7 @@ def com_google_fonts_check_iso15008_interword_spacing(font, ttFont): # Add spacing caused by normal sidebearings space_width += m_rsb + n_lsb - if 2.50 <= space_width / l_m <= 3.0: - yield PASS, "Advance width of interword space was adequate" - else: + if not 2.50 <= space_width / l_m <= 3.0: yield FAIL, Message( "bad-interword-spacing", f"The interword space ({space_width}) was" @@ -340,12 +327,9 @@ def com_google_fonts_check_iso15008_interline_spacing(ttFont): width = stem_width(ttFont) if width is None: yield FAIL, Message("no-stem-width", "Could not determine stem width") - return - if linegap < width: + elif linegap < width: yield FAIL, Message( "bad-interline-spacing", f"The interline space {linegap} should" f" be more than the stem width {width}", ) - return - yield PASS, "Amount of interline space was adequate" From 030c4b0ce3756a3e34e5157c6730f710c32f3a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 02:38:50 -0300 Subject: [PATCH 29/46] simplify PASS results - notofonts profile (issue #4612) --- Lib/fontbakery/checks/notofonts.py | 43 +++--------------------------- 1 file changed, 4 insertions(+), 39 deletions(-) diff --git a/Lib/fontbakery/checks/notofonts.py b/Lib/fontbakery/checks/notofonts.py index a964e5a686..f89724da75 100644 --- a/Lib/fontbakery/checks/notofonts.py +++ b/Lib/fontbakery/checks/notofonts.py @@ -91,7 +91,6 @@ def com_google_fonts_check_cmap_unexpected_subtables(font): yield FAIL, Message("font-lacks-OS/2-table", "Font lacks 'OS/2' table.") return - passed = True # Note: # Format 0 = Byte encoding table # Format 4 = Segment mapping to delta values @@ -150,15 +149,12 @@ def com_google_fonts_check_cmap_unexpected_subtables(font): subtable.platformID, subtable.platEncID, ) not in EXPECTED_SUBTABLES: - passed = False yield WARN, Message( "unexpected-subtable", f"'cmap' has a subtable of" f" (format={subtable.format}, platform={subtable.platformID}," f" encoding={subtable.platEncID}), which it shouldn't have.", ) - if passed: - yield PASS, "All cmap subtables look good!" def unicoderange(ttFont): @@ -194,9 +190,7 @@ def com_google_fonts_check_unicode_range_bits(ttFont): expected_unicoderange = compute_unicoderange_bits(ttFont) difference = unicoderange(ttFont) ^ expected_unicoderange - if not difference: - yield PASS, "Looks good!" - else: + if difference: for bit in range(128): if difference & (1 << bit): range_name = unicoderange_bit_name(bit) @@ -228,11 +222,9 @@ def com_google_fonts_check_noto_manufacturer(ttFont): """Ensure the manufacturer is a known Noto manufacturer and the URL is correct.""" from fontbakery.utils import get_name_entry_strings - bad = False manufacturers = get_name_entry_strings(ttFont, NameID.MANUFACTURER_NAME) good_manufacturer = None if not manufacturers: - bad = True yield FAIL, Message( "no-manufacturer", "The font contained no manufacturer name" ) @@ -243,7 +235,6 @@ def com_google_fonts_check_noto_manufacturer(ttFont): if m: good_manufacturer = m[0] else: - bad = True yield WARN, Message( "unknown-manufacturer", f"The font's manufacturer name '{manufacturer}' was" @@ -252,8 +243,8 @@ def com_google_fonts_check_noto_manufacturer(ttFont): designer_urls = get_name_entry_strings(ttFont, NameID.DESIGNER_URL) if not designer_urls: - bad = True yield WARN, Message("no-designer-urls", "The font contained no designer URL") + if good_manufacturer: expected_url = MANUFACTURERS_URLS[good_manufacturer] for designer_url in designer_urls: @@ -263,8 +254,6 @@ def com_google_fonts_check_noto_manufacturer(ttFont): f"The font's designer URL was '{designer_url}'" f" but should have been '{expected_url}'", ) - if not bad: - yield PASS, "The manufacturer name and designer URL entries were valid" @check( @@ -278,22 +267,17 @@ def com_google_fonts_check_noto_designer(ttFont): """Ensure the designer is a known Noto designer.""" from fontbakery.utils import get_name_entry_strings - bad = False designers = get_name_entry_strings(ttFont, NameID.DESIGNER) if not designers: - bad = True yield FAIL, Message("no-designer", "The font contained no designer name") for designer in designers: if designer not in NOTO_DESIGNERS: - bad = True yield WARN, Message( "unknown-designer", f"The font's designer name '{designer}' was " "not a known Noto font designer", ) - if not bad: - yield PASS, "The designer name entry was valid" @check( @@ -307,23 +291,17 @@ def com_google_fonts_check_noto_trademark(ttFont): """Ensure the trademark matches the expected string.""" from fontbakery.utils import get_name_entry_strings - bad = False trademarks = get_name_entry_strings(ttFont, NameID.TRADEMARK) if not trademarks: - bad = True yield FAIL, Message("no-trademark", "The font contained no trademark entry") for trademark in trademarks: if not re.match(TRADEMARK, trademark): - bad = True yield FAIL, Message( "bad-trademark", f"The trademark entry should be '{TRADEMARK}' " f"but was actually '{trademark}'", ) - if not bad: - yield PASS, "The trademark name entry was valid" - @check( id="com.google.fonts/check/cmap/format_12", @@ -336,7 +314,6 @@ def com_google_fonts_check_noto_trademark(ttFont): ) def com_google_fonts_check_cmap_format_12(ttFont, config): """Check that format 12 cmap subtables are correctly constituted.""" - bad = False skipped = True # Find the format 4 cmap4 = None @@ -357,12 +334,12 @@ def com_google_fonts_check_cmap_format_12(ttFont, config): skipped = False codepoints = subtable.cmap.keys() if not any(cp > 0x0FFF for cp in codepoints): - bad = True yield FAIL, Message( "pointless-format-12", "A format 12 subtable did not contain" " any codepoints beyond the Basic Multilingual Plane (BMP)", ) + unmapped_from_4 = set(cmap4.cmap.keys()) - set(codepoints) if unmapped_from_4: from fontbakery.utils import pretty_print_list @@ -376,8 +353,6 @@ def com_google_fonts_check_cmap_format_12(ttFont, config): if skipped: yield SKIP, "No format 12 subtables found" - elif not bad: - yield PASS, "All format 12 subtables were correctly formed" @check( @@ -395,8 +370,6 @@ def com_google_fonts_check_os2_noto_vendor(ttFont): yield FAIL, Message( "bad-vendor-id", f"OS/2 VendorID is '{vendor_id}', but should be 'GOOG'." ) - else: - yield PASS, f"OS/2 VendorID '{vendor_id}' is correct." @check( @@ -408,26 +381,22 @@ def com_google_fonts_check_os2_noto_vendor(ttFont): ) def com_google_fonts_check_htmx_encoded_latin_digits(ttFont): """Check all encoded Latin digits have the same advance width""" - bad = False digits = "0123456789" zero_width = _get_advance_width_for_char(ttFont, "0") if zero_width is None: yield SKIP, "No encoded Latin digits" return + for d in digits: actual_width = _get_advance_width_for_char(ttFont, d) if actual_width is None: - bad = True yield FAIL, Message("missing-digit", f"Missing Latin digit {d}") elif actual_width != zero_width: - bad = True yield FAIL, Message( "bad-digit-width", f"Width of {d} was expected to be " f"{zero_width} but was {actual_width}", ) - if not bad: - yield PASS, "All Latin digits had same advance width" @check( @@ -448,8 +417,6 @@ def com_google_fonts_check_htmx_comma_period(ttFont): "comma-period", f"Advance width of comma ({comma}) != advance width" f" of period {period}", ) - else: - yield PASS, "Comma and period had the same advance width" @check( @@ -516,8 +483,6 @@ def com_google_fonts_check_htmx_whitespace_advances( "bad-whitespace-advances", f"The following glyphs had wrong advance widths:\n" f"{formatted_list}", ) - else: - yield PASS, "Whitespace glyphs had correct advance widths" @check( From 78496ddef29f775f94aa32353dab2dba38cd447c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 02:42:27 -0300 Subject: [PATCH 30/46] simplify PASS results - opentype profile (cff) (issue #4612) --- Lib/fontbakery/checks/opentype/cff.py | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/Lib/fontbakery/checks/opentype/cff.py b/Lib/fontbakery/checks/opentype/cff.py index 68f92d3bab..dc7cf05503 100644 --- a/Lib/fontbakery/checks/opentype/cff.py +++ b/Lib/fontbakery/checks/opentype/cff.py @@ -1,6 +1,6 @@ from fontbakery.callable import check, condition from fontbakery.testable import Font, TTCFont -from fontbakery.status import FAIL, PASS, WARN +from fontbakery.status import FAIL, WARN from fontbakery.message import Message @@ -153,23 +153,17 @@ def com_adobe_fonts_check_cff_call_depth(font): """Is the CFF subr/gsubr call depth > 10?""" analysis = font.cff_analysis - any_failures = False - if analysis.glyphs_exceed_max or analysis.glyphs_recursion_errors: - any_failures = True for gn in analysis.glyphs_exceed_max: yield FAIL, Message( "max-depth", - f"Subroutine call depth exceeded" f' maximum of 10 for glyph "{gn}".', + f'Subroutine call depth exceeded maximum of 10 for glyph "{gn}".', ) for gn in analysis.glyphs_recursion_errors: yield FAIL, Message( "recursion-error", f'Recursion error while decompiling glyph "{gn}".' ) - if not any_failures: - yield PASS, "Maximum call depth not exceeded." - @check( id="com.adobe.fonts/check/cff2_call_depth", @@ -182,24 +176,19 @@ def com_adobe_fonts_check_cff_call_depth(font): def com_adobe_fonts_check_cff2_call_depth(font): """Is the CFF2 subr/gsubr call depth > 10?""" - any_failures = False analysis = font.cff_analysis if analysis.glyphs_exceed_max or analysis.glyphs_recursion_errors: - any_failures = True for gn in analysis.glyphs_exceed_max: yield FAIL, Message( "max-depth", - f"Subroutine call depth exceeded" f' maximum of 10 for glyph "{gn}".', + f'Subroutine call depth exceeded maximum of 10 for glyph "{gn}".', ) for gn in analysis.glyphs_recursion_errors: yield FAIL, Message( "recursion-error", f'Recursion error while decompiling glyph "{gn}".' ) - if not any_failures: - yield PASS, "Maximum call depth not exceeded." - @check( id="com.adobe.fonts/check/cff_deprecated_operators", @@ -216,10 +205,8 @@ def com_adobe_fonts_check_cff2_call_depth(font): ) def com_adobe_fonts_check_cff_deprecated_operators(cff_analysis): """Does the font use deprecated CFF operators or operations?""" - any_failures = False if cff_analysis.glyphs_dotsection or cff_analysis.glyphs_endchar_seac: - any_failures = True for gn in cff_analysis.glyphs_dotsection: yield WARN, Message( "deprecated-operator-dotsection", @@ -231,6 +218,3 @@ def com_adobe_fonts_check_cff_deprecated_operators(cff_analysis): f'Glyph "{gn}" has deprecated use of "endchar"' f" operator to build accented characters (seac).", ) - - if not any_failures: - yield PASS, "No deprecated CFF operators used." From 4f10100159dfe1a20645be902b6800f15732a1dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 02:46:36 -0300 Subject: [PATCH 31/46] simplify PASS results - opentype profile (dsig) (issue #4612) --- Lib/fontbakery/checks/opentype/dsig.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/fontbakery/checks/opentype/dsig.py b/Lib/fontbakery/checks/opentype/dsig.py index f2984ef62d..3364a7b6af 100644 --- a/Lib/fontbakery/checks/opentype/dsig.py +++ b/Lib/fontbakery/checks/opentype/dsig.py @@ -1,5 +1,5 @@ from fontbakery.callable import check -from fontbakery.status import WARN, PASS +from fontbakery.status import WARN from fontbakery.message import Message @@ -28,9 +28,7 @@ ) def com_google_fonts_check_dsig(ttFont): """Does the font have a DSIG table?""" - if "DSIG" not in ttFont: - yield PASS, "ok" - else: + if "DSIG" in ttFont: yield WARN, Message( "found-DSIG", "This font has a digital signature (DSIG table) which" From 5c7b08903bc67dcc7dd508a87286f998a5285272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 02:50:56 -0300 Subject: [PATCH 32/46] simplify PASS results - opentype profile (fvar) (issue #4612) --- Lib/fontbakery/checks/opentype/fvar.py | 66 +++----------------------- tests/checks/opentype/fvar_test.py | 45 +++++++----------- 2 files changed, 24 insertions(+), 87 deletions(-) diff --git a/Lib/fontbakery/checks/opentype/fvar.py b/Lib/fontbakery/checks/opentype/fvar.py index 56e5ac26a1..af79aa907c 100644 --- a/Lib/fontbakery/checks/opentype/fvar.py +++ b/Lib/fontbakery/checks/opentype/fvar.py @@ -180,12 +180,10 @@ def com_google_fonts_check_varfont_wght_valid_range(ttFont): """The variable font 'wght' (Weight) axis coordinate must be within spec range of 1 to 1000 on all instances.""" - passed = True for instance in ttFont["fvar"].instances: if "wght" in instance.coordinates: value = instance.coordinates["wght"] if value < 1 or value > 1000: - passed = False yield FAIL, Message( "wght-out-of-range", f'Found a bad "wght" coordinate with value {value}' @@ -193,9 +191,6 @@ def com_google_fonts_check_varfont_wght_valid_range(ttFont): ) break - if passed: - yield PASS, "OK" - @check( id="com.google.fonts/check/varfont/wdth_valid_range", @@ -214,18 +209,17 @@ def com_google_fonts_check_varfont_wdth_valid_range(ttFont): """The variable font 'wdth' (Width) axis coordinate must strictly greater than zero.""" - passed = True for instance in ttFont["fvar"].instances: if "wdth" in instance.coordinates: value = instance.coordinates["wdth"] if value < 1: - passed = False yield FAIL, Message( "wdth-out-of-range", f'Found a bad "wdth" coordinate with value {value}' f" outside of the valid range (> 0).", ) break + if value > 1000: yield WARN, Message( "wdth-greater-than-1000", @@ -234,9 +228,6 @@ def com_google_fonts_check_varfont_wdth_valid_range(ttFont): ) break - if passed: - yield PASS, "OK" - @check( id="com.google.fonts/check/varfont/slnt_range", @@ -256,9 +247,7 @@ def com_google_fonts_check_varfont_slnt_range(ttFont, slnt_axis): """The variable font 'slnt' (Slant) axis coordinate specifies positive values in its range?""" - if slnt_axis.minValue < 0 and slnt_axis.maxValue >= 0: - yield PASS, "Looks good!" - else: + if not (slnt_axis.minValue < 0 and slnt_axis.maxValue >= 0): yield WARN, Message( "unusual-slnt-range", f'The range of values for the "slnt" axis in' @@ -287,9 +276,7 @@ def com_typenetwork_check_varfont_ital_range(ttFont, ital_axis): """The variable font 'ital' (Italic) axis coordinates is in a valid range?""" - if ital_axis.minValue == 0 and ital_axis.maxValue == 1: - yield PASS, "Looks good!" - else: + if not (ital_axis.minValue == 0 and ital_axis.maxValue == 1): yield FAIL, Message( "invalid-ital-range", f'The range of values for the "ital" axis in' @@ -322,9 +309,7 @@ def com_adobe_fonts_check_varfont_valid_axis_nameid(ttFont, has_name_table): yield FAIL, Message("lacks-table", "Font lacks 'name' table.") return - passed = True name_table = ttFont["name"] - font_axis_nameids = [axis.axisNameID for axis in ttFont["fvar"].axes] invalid_axis_nameids = [val for val in font_axis_nameids if not (255 < val < 32768)] @@ -336,10 +321,6 @@ def com_adobe_fonts_check_varfont_valid_axis_nameid(ttFont, has_name_table): f"{inst_name!r} instance has an axisNameID value that" " is not greater than 255 and less than 32768.", ) - passed = False - - if passed: - yield PASS, "All axisNameID values are valid." @check( @@ -365,9 +346,7 @@ def com_adobe_fonts_check_varfont_valid_subfamily_nameid(ttFont, has_name_table) yield FAIL, Message("lacks-table", "Font lacks 'name' table.") return - passed = True name_table = ttFont["name"] - font_subfam_nameids = [inst.subfamilyNameID for inst in ttFont["fvar"].instances] invalid_subfam_nameids = [ val @@ -383,10 +362,6 @@ def com_adobe_fonts_check_varfont_valid_subfamily_nameid(ttFont, has_name_table) f"{inst_name!r} instance has a subfamilyNameID value that" " is neither 2, 17, or greater than 255 and less than 32768.", ) - passed = False - - if passed: - yield PASS, "All subfamilyNameID values are valid." @check( @@ -412,9 +387,7 @@ def com_adobe_fonts_check_varfont_valid_postscript_nameid(ttFont, has_name_table yield FAIL, Message("lacks-table", "Font lacks 'name' table.") return - passed = True name_table = ttFont["name"] - font_postscript_nameids = [ inst.postscriptNameID for inst in ttFont["fvar"].instances ] @@ -430,12 +403,8 @@ def com_adobe_fonts_check_varfont_valid_postscript_nameid(ttFont, has_name_table yield FAIL, Message( f"invalid-postscript-nameid:{nameid}", f"{inst_name!r} instance has a postScriptNameID value that" - " is neither 6, 0xFFFF, or greater than 255 and less than 32768.", + f" is neither 6, 0xFFFF, or greater than 255 and less than 32768.", ) - passed = False - - if passed: - yield PASS, "All postScriptNameID values are valid." @check( @@ -471,7 +440,6 @@ def com_adobe_fonts_check_varfont_valid_default_instance_nameids( yield FAIL, Message("lacks-table", "Font lacks 'name' table.") return - passed = True name_table = ttFont["name"] fvar_table = ttFont["fvar"] @@ -504,7 +472,6 @@ def com_adobe_fonts_check_varfont_valid_default_instance_nameids( f"{subfam_name!r} instance has the same coordinates as the default" f" instance; its subfamily name should be {font_subfam_name!r}", ) - passed = False # Validate the postScriptNameID string only if # at least one instance record includes it @@ -515,10 +482,6 @@ def com_adobe_fonts_check_varfont_valid_default_instance_nameids( f" instance; its postscript name should be {name6!r}, instead of" f" {postscript_name!r}.", ) - passed = False - - if passed: - yield PASS, "All default instance name strings are valid." @check( @@ -539,7 +502,8 @@ def com_adobe_fonts_check_varfont_same_size_instance_records(ttFont): """Validates that all of the instance records in a given font have the same size.""" if not ttFont["fvar"].instances: - return SKIP, Message("no-instance-records", "Font has no instance records.") + yield SKIP, Message("no-instance-records", "Font has no instance records.") + return font_ps_nameids_not_provided = set( inst.postscriptNameID == 0xFFFF for inst in ttFont["fvar"].instances @@ -550,13 +514,11 @@ def com_adobe_fonts_check_varfont_same_size_instance_records(ttFont): # it means that some instance records have postscriptNameID values while # others do not. if len(font_ps_nameids_not_provided) != 1: - return FAIL, Message( + yield FAIL, Message( "different-size-instance-records", "Instance records don't all have the same size.", ) - return PASS, "All instance records have the same size." - @check( id="com.adobe.fonts/check/varfont/distinct_instance_records", @@ -579,9 +541,7 @@ def com_adobe_fonts_check_varfont_distinct_instance_records(ttFont, has_name_tab yield FAIL, Message("lacks-table", "Font lacks 'name' table.") return - passed = True name_table = ttFont["name"] - unique_inst_recs = set() for i, inst in enumerate(ttFont["fvar"].instances, 1): @@ -603,10 +563,6 @@ def com_adobe_fonts_check_varfont_distinct_instance_records(ttFont, has_name_tab f"repeated-instance-record:{inst_name}", f"{inst_name!r} is a repeated instance record.", ) - passed = False - - if passed: - yield PASS, "All instance records are distinct." @check( @@ -624,7 +580,6 @@ def com_adobe_fonts_check_varfont_distinct_instance_records(ttFont, has_name_tab ) def com_adobe_fonts_check_varfont_foundry_defined_tag_name(ttFont): "Validate foundry-defined design-variation axis tag names." - passed = True for axis in ttFont["fvar"].axes: axisTag = axis.axisTag if axisTag in REGISTERED_AXIS_TAGS: @@ -640,7 +595,6 @@ def com_adobe_fonts_check_varfont_foundry_defined_tag_name(ttFont): firstChar = ord(axisTag[0]) if not (firstChar >= ord("A") and firstChar <= ord("Z")): - passed = False yield FAIL, Message( "invalid-foundry-defined-tag-first-letter", f'Please fix axis tag "{axisTag}".\n' @@ -653,7 +607,6 @@ def com_adobe_fonts_check_varfont_foundry_defined_tag_name(ttFont): (char >= ord("0") and char <= ord("9")) or (char >= ord("A") and char <= ord("Z")) ): - passed = False yield FAIL, Message( "invalid-foundry-defined-tag-chars", f'Please fix axis tag "{axisTag}".\n' @@ -661,9 +614,6 @@ def com_adobe_fonts_check_varfont_foundry_defined_tag_name(ttFont): f" uppercase or digits.", ) - if passed: - yield PASS, f"Axis tag '{axisTag}' looks good." - @check( id="com.google.fonts/check/varfont/family_axis_ranges", @@ -692,5 +642,3 @@ def axis_info(ttFont): "axis-range-mismatch", "Variable axes ranges not matching between font files", ) - else: - yield PASS, "Variable axes ranges are matching between font files" diff --git a/tests/checks/opentype/fvar_test.py b/tests/checks/opentype/fvar_test.py index 3a5c794537..53e3c0b1b8 100644 --- a/tests/checks/opentype/fvar_test.py +++ b/tests/checks/opentype/fvar_test.py @@ -19,7 +19,7 @@ def test_check_varfont_regular_wght_coord(): # Our reference varfont CabinVFBeta.ttf # has a good Regular:wght coordinate ttFont = TTFont("data/test/cabinvfbeta/CabinVFBeta.ttf") - assert assert_PASS(check(ttFont)) == "Regular:wght is 400." + assert_PASS(check(ttFont)) # We then ensure the check detects it when we # introduce the problem by setting a bad value: @@ -46,7 +46,7 @@ def test_check_varfont_regular_wght_coord(): # Test with an italic variable font. The Italic instance must also be 400 ttFont = TTFont(TEST_FILE("varfont/OpenSans-Italic[wdth,wght].ttf")) - assert assert_PASS(check(ttFont)) == "Regular:wght is 400." + assert_PASS(check(ttFont)) # Now test with a static font. # The test should be skipped due to an unfulfilled condition. @@ -63,7 +63,7 @@ def test_check_varfont_regular_wdth_coord(): # Our reference varfont CabinVFBeta.ttf # has a good Regular:wdth coordinate ttFont = TTFont("data/test/cabinvfbeta/CabinVFBeta.ttf") - assert assert_PASS(check(ttFont)) == "Regular:wdth is 100." + assert_PASS(check(ttFont)) # We then ensure the check detects it when we # introduce the problem by setting a bad value: @@ -90,7 +90,7 @@ def test_check_varfont_regular_wdth_coord(): # Test with an italic variable font. The Italic instance must also be 100 ttFont = TTFont(TEST_FILE("varfont/OpenSans-Italic[wdth,wght].ttf")) - assert assert_PASS(check(ttFont)) == "Regular:wdth is 100." + assert_PASS(check(ttFont)) # Now test with a static font. # The test should be skipped due to an unfulfilled condition. @@ -127,7 +127,7 @@ def test_check_varfont_regular_slnt_coord(): # We correct the slant coordinate value to make the check PASS. first_instance.coordinates["slnt"] = 0 - assert assert_PASS(check(ttFont)) == "Regular:slnt is zero." + assert_PASS(check(ttFont)) # Change the name of the first instance from 'Regular' (nameID 258) # to 'Medium' (nameID 259). The font now has no Regular instance. @@ -176,7 +176,7 @@ def test_check_varfont_regular_ital_coord(): # We correct the italic coordinate value to make the check PASS. first_instance.coordinates["ital"] = 0 - assert assert_PASS(check(ttFont)) == "Regular:ital is zero." + assert_PASS(check(ttFont)) # Change the name of the first instance from 'Regular' (nameID 258) # to 'Medium' (nameID 259). The font now has no Regular instance. @@ -360,8 +360,7 @@ def test_check_varfont_valid_axis_nameid(): # The axisNameID values in the reference varfont are all valid ttFont = TTFont("data/test/cabinvf/Cabin[wdth,wght].ttf") - msg = assert_PASS(check(ttFont), "with a good varfont...") - assert msg == "All axisNameID values are valid." + assert_PASS(check(ttFont), "with a good varfont...") fvar_table = ttFont["fvar"] wght_axis = fvar_table.axes[0] @@ -370,8 +369,7 @@ def test_check_varfont_valid_axis_nameid(): # Change the axes' axisNameID to the maximum and minimum allowed values wght_axis.axisNameID = 32767 wdth_axis.axisNameID = 256 - msg = assert_PASS(check(ttFont), "with a good varfont...") - assert msg == "All axisNameID values are valid." + assert_PASS(check(ttFont), "with a good varfont...") # Change the axes' axisNameID to invalid values # (32768 is greater than the maximum, and 255 is less than the minimum) @@ -406,8 +404,7 @@ def test_check_varfont_valid_subfamily_nameid(): # The subfamilyNameID values in the reference varfont are all valid ttFont = TTFont("data/test/cabinvf/Cabin[wdth,wght].ttf") - msg = assert_PASS(check(ttFont), "with a good varfont...") - assert msg == "All subfamilyNameID values are valid." + assert_PASS(check(ttFont), "with a good varfont...") fvar_table = ttFont["fvar"] inst_1 = fvar_table.instances[0] @@ -421,8 +418,7 @@ def test_check_varfont_valid_subfamily_nameid(): inst_2.subfamilyNameID = 17 inst_3.subfamilyNameID = 256 inst_4.subfamilyNameID = 32767 - msg = assert_PASS(check(ttFont), "with a good varfont...") - assert msg == "All subfamilyNameID values are valid." + assert_PASS(check(ttFont), "with a good varfont...") # Change two instances' subfamilyNameID to invalid values # (32768 is greater than the maximum, and 255 is less than the minimum) @@ -460,8 +456,7 @@ def test_check_varfont_valid_postscript_nameid(): # The postScriptNameID values in the reference varfont are all valid ttFont = TTFont("data/test/cabinvf/Cabin[wdth,wght].ttf") - msg = assert_PASS(check(ttFont), "with a good varfont...") - assert msg == "All postScriptNameID values are valid." + assert_PASS(check(ttFont), "with a good varfont...") fvar_table = ttFont["fvar"] inst_1 = fvar_table.instances[0] @@ -475,8 +470,7 @@ def test_check_varfont_valid_postscript_nameid(): inst_2.postscriptNameID = 0xFFFF inst_3.postscriptNameID = 256 inst_4.postscriptNameID = 32767 - msg = assert_PASS(check(ttFont), "with a good varfont...") - assert msg == "All postScriptNameID values are valid." + assert_PASS(check(ttFont), "with a good varfont...") # Change two instances' postScriptNameID to invalid values # (32768 is greater than the maximum, and 255 is less than the minimum) @@ -516,14 +510,12 @@ def test_check_varfont_valid_default_instance_nameids(): # The font's 'Regular' instance record has the same coordinates as the default # instance, and the record's string matches the string of nameID 2. ttFont_1 = TTFont(TEST_FILE("cabinvf/Cabin[wdth,wght].ttf")) - msg = assert_PASS(check(ttFont_1)) - assert msg == "All default instance name strings are valid." + assert_PASS(check(ttFont_1)) # The font's 'LightCondensed' instance record has the same coordinates as the # default instance, and the record's string matches the string of nameID 17. ttFont_2 = TTFont(TEST_FILE("mutatorsans-vf/MutatorSans-VF.ttf")) - msg = assert_PASS(check(ttFont_2)) - assert msg == "All default instance name strings are valid." + assert_PASS(check(ttFont_2)) # Change subfamilyNameID value of the default instance to another name ID whose # string doesn't match the font's Subfamily name, thus making the check fail. @@ -593,8 +585,7 @@ def test_check_varfont_same_size_instance_records(): # The value of postScriptNameID is 0xFFFF for all the instance records in the # reference varfont ttFont = TTFont("data/test/cabinvf/Cabin[wdth,wght].ttf") - msg = assert_PASS(check(ttFont), "with a good varfont...") - assert msg == "All instance records have the same size." + assert_PASS(check(ttFont), "with a good varfont...") fvar_table = ttFont["fvar"] inst_1 = fvar_table.instances[0] @@ -611,8 +602,7 @@ def test_check_varfont_same_size_instance_records(): inst_2.postscriptNameID = 356 inst_3.postscriptNameID = 456 inst_4.postscriptNameID = 556 - msg = assert_PASS(check(ttFont), "with a good varfont...") - assert msg == "All instance records have the same size." + assert_PASS(check(ttFont), "with a good varfont...") # Change the postScriptNameID of two instance records inst_1.postscriptNameID = 0xFFFF @@ -632,8 +622,7 @@ def test_check_varfont_distinct_instance_records(): # All of the instance records in the reference varfont are unique ttFont = TTFont("data/test/cabinvf/Cabin[wdth,wght].ttf") - msg = assert_PASS(check(ttFont), "with a good varfont...") - assert msg == "All instance records are distinct." + assert_PASS(check(ttFont), "with a good varfont...") fvar_table = ttFont["fvar"] inst_1 = fvar_table.instances[0] From e90da3d77a9e21207177777120df0613f4f8f5b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 02:55:11 -0300 Subject: [PATCH 33/46] simplify PASS results - opentype profile (gdef) (issue #4612) --- Lib/fontbakery/checks/opentype/gdef.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Lib/fontbakery/checks/opentype/gdef.py b/Lib/fontbakery/checks/opentype/gdef.py index be9d3363da..fa98a82be9 100644 --- a/Lib/fontbakery/checks/opentype/gdef.py +++ b/Lib/fontbakery/checks/opentype/gdef.py @@ -1,5 +1,5 @@ from fontbakery.callable import check -from fontbakery.status import PASS, WARN, SKIP +from fontbakery.status import WARN, SKIP from fontbakery.message import Message @@ -67,10 +67,6 @@ def com_google_fonts_check_gdef_spacing_marks(ttFont, config): f" the GDEF mark glyph class by mistake:\n" f"{formatted_list}", ) - else: - yield PASS, ( - "Font does not has spacing glyphs in the GDEF mark glyph class." - ) else: yield SKIP, ( 'Font does not declare an optional "GDEF" table' @@ -111,11 +107,6 @@ def com_google_fonts_check_gdef_mark_chars(ttFont, config): f" in the GDEF mark glyph class:\n" f"{formatted_marks}", ) - else: - yield PASS, ( - "Font does not have mark characters" - " not in the GDEF mark glyph class." - ) else: yield SKIP, ( 'Font does not declare an optional "GDEF" table' @@ -174,11 +165,6 @@ def com_google_fonts_check_gdef_non_mark_chars(ttFont, config): f" not be in the GDEF mark glyph class:\n" f"{formatted_nonmarks}", ) - else: - yield PASS, ( - "Font does not have non-mark characters" - " in the GDEF mark glyph class." - ) else: yield SKIP, ( 'Font does not declare an optional "GDEF" table' From 304f1e28692c515ba9a666445aad7f9fd6ffdbbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 02:57:06 -0300 Subject: [PATCH 34/46] simplify PASS results - opentype profile (glyf) (issue #4612) --- Lib/fontbakery/checks/opentype/glyf.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Lib/fontbakery/checks/opentype/glyf.py b/Lib/fontbakery/checks/opentype/glyf.py index 796cf73de4..de96e5ceaf 100644 --- a/Lib/fontbakery/checks/opentype/glyf.py +++ b/Lib/fontbakery/checks/opentype/glyf.py @@ -96,8 +96,6 @@ def com_google_fonts_check_points_out_of_bounds(ttFont, config): f" calligraphic-script, handwriting, rounded and" f" other fonts. So it is common to ignore this message.", ) - else: - yield PASS, "All glyph paths have coordinates within bounds!" @check( @@ -145,8 +143,3 @@ def com_google_fonts_check_glyf_non_transformed_duplicate_components(ttFont, con f" have the same x,y coordinates:\n" f"{formatted_list}", ) - else: - yield PASS, ( - "Glyphs do not contain duplicate components which have" - " the same x,y coordinates." - ) From 7cf8ac544f202ee3f30dc18be591bedf8f1db9d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 02:57:58 -0300 Subject: [PATCH 35/46] simplify PASS results - opentype profile (gpos) (issue #4612) --- Lib/fontbakery/checks/opentype/gpos.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Lib/fontbakery/checks/opentype/gpos.py b/Lib/fontbakery/checks/opentype/gpos.py index b9f7b2fc4c..e55467acc5 100644 --- a/Lib/fontbakery/checks/opentype/gpos.py +++ b/Lib/fontbakery/checks/opentype/gpos.py @@ -1,6 +1,6 @@ from fontbakery.callable import check, condition from fontbakery.testable import Font -from fontbakery.status import PASS, WARN +from fontbakery.status import WARN from fontbakery.message import Message @@ -41,5 +41,3 @@ def com_google_fonts_check_gpos_kerning_info(font): """ if font.ttFont["post"].isFixedPitch == 0 and not font.has_kerning_info: yield WARN, Message("lacks-kern-info", "GPOS table lacks kerning information.") - else: - yield PASS, "GPOS table check for kerning information passed." From 496bcae49e60068e919727b55eea1bc7dec03431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 02:59:52 -0300 Subject: [PATCH 36/46] simplify PASS results - opentype profile (head) (issue #4612) --- Lib/fontbakery/checks/opentype/head.py | 15 +-------------- tests/checks/opentype/head_test.py | 3 --- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/Lib/fontbakery/checks/opentype/head.py b/Lib/fontbakery/checks/opentype/head.py index 97f0420276..f74bba24b3 100644 --- a/Lib/fontbakery/checks/opentype/head.py +++ b/Lib/fontbakery/checks/opentype/head.py @@ -1,7 +1,7 @@ import fractions from fontbakery.callable import check -from fontbakery.status import FAIL, PASS, WARN +from fontbakery.status import FAIL, WARN from fontbakery.message import Message from fontbakery.constants import NameID @@ -37,8 +37,6 @@ def com_google_fonts_check_family_equal_font_versions(ttFonts): f"These were the version values found:\n" f"{versions_list}", ) - else: - yield PASS, "All font files have the same version." @check( @@ -81,10 +79,6 @@ def com_google_fonts_check_unitsperem(ttFont): f" common and may be just fine as well." f" But we got {upem} instead.", ) - else: - yield PASS, ( - f"The unitsPerEm value ({upem}) on" f" the 'head' table is reasonable." - ) def parse_version_string(name: str) -> float: @@ -146,13 +140,11 @@ def com_google_fonts_check_font_version(ttFont): if record.nameID == NameID.VERSION_STRING ] - failed = False if name_id_5_records: for record in name_id_5_records: try: name_version = parse_version_string(record.toUnicode()) if abs(name_version - head_version) > fail_tolerance: - failed = True yield FAIL, Message( "mismatch", f'head version is "{float(head_version):.5f}"' @@ -173,7 +165,6 @@ def com_google_fonts_check_font_version(ttFont): f" is not as accurate as possible.", ) except ValueError: - failed = True yield FAIL, Message( "parse", f"name version string for" @@ -183,14 +174,10 @@ def com_google_fonts_check_font_version(ttFont): f" could not be parsed.", ) else: - failed = True yield FAIL, Message( "missing", "There is no name ID 5 (version string) in the font." ) - if not failed: - yield PASS, "All font version fields match." - @check( id="com.google.fonts/check/mac_style", diff --git a/tests/checks/opentype/head_test.py b/tests/checks/opentype/head_test.py index 649dab8d1c..96b5251efb 100644 --- a/tests/checks/opentype/head_test.py +++ b/tests/checks/opentype/head_test.py @@ -142,9 +142,6 @@ def test_check_font_version(): # There should be at least one WARN... assert_results_contain(check(test_font), WARN, "near-mismatch") - # But final result is a PASS: - assert_PASS(check(test_font)) - # Test that having more than 3 decimal places in the version # in the Name table is acceptable. # See https://github.com/fonttools/fontbakery/issues/2928 From 5cd90d713c9a121969e27c909d792fc1266bd077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 03:00:26 -0300 Subject: [PATCH 37/46] simplify PASS results - opentype profile (hhea) (issue #4612) --- Lib/fontbakery/checks/opentype/hhea.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Lib/fontbakery/checks/opentype/hhea.py b/Lib/fontbakery/checks/opentype/hhea.py index 8ba25e6738..78f2188808 100644 --- a/Lib/fontbakery/checks/opentype/hhea.py +++ b/Lib/fontbakery/checks/opentype/hhea.py @@ -1,5 +1,5 @@ from fontbakery.callable import check -from fontbakery.status import FAIL, PASS +from fontbakery.status import FAIL from fontbakery.message import Message @@ -37,10 +37,6 @@ def com_google_fonts_check_maxadvancewidth(ttFont): f" expected {hmtx_advance_width_max} (from hmtx);" f" got {hhea_advance_width_max} (from hhea)", ) - else: - yield PASS, ( - "MaxAdvanceWidth is consistent with values in the Hmtx and Hhea tables." - ) @check( @@ -94,7 +90,3 @@ def com_google_fonts_check_caret_slope(ttFont): f"Expected: caretSlopeRise {expectedCaretSlopeRise}" f" and caretSlopeRun {expectedCaretSlopeRun}", ) - else: - yield PASS, ( - "hhea.caretSlopeRise and hhea.caretSlopeRun match with post.italicAngle." - ) From cecaf68261ddb68c2b8052d32ff8d53f0763e8ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 03:02:18 -0300 Subject: [PATCH 38/46] simplify PASS results - opentype profile (kern) (issue #4612) --- Lib/fontbakery/checks/opentype/kern.py | 69 +++++++++++++------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/Lib/fontbakery/checks/opentype/kern.py b/Lib/fontbakery/checks/opentype/kern.py index b8f5f087c7..ccc527a149 100644 --- a/Lib/fontbakery/checks/opentype/kern.py +++ b/Lib/fontbakery/checks/opentype/kern.py @@ -35,39 +35,40 @@ def com_google_fonts_check_kern_table(ttFont): """Is there a usable "kern" table declared in the font?""" kern = ttFont.get("kern") - if kern: - # Scour all cmap tables for encoded glyphs. - characterGlyphs = set() - for table in ttFont["cmap"].tables: - characterGlyphs.update(table.cmap.values()) + if not kern: + yield PASS, 'Font does not declare an optional "kern" table.' + return + + # Scour all cmap tables for encoded glyphs. + characterGlyphs = set() + for table in ttFont["cmap"].tables: + characterGlyphs.update(table.cmap.values()) - nonCharacterGlyphs = set() - for kernTable in kern.kernTables: - if kernTable.format == 0: - for leftGlyph, rightGlyph in kernTable.kernTable.keys(): - if leftGlyph not in characterGlyphs: - nonCharacterGlyphs.add(leftGlyph) - if rightGlyph not in characterGlyphs: - nonCharacterGlyphs.add(rightGlyph) - if all(kernTable.format != 0 for kernTable in kern.kernTables): - yield WARN, Message( - "kern-unknown-format", - 'The "kern" table does not have any format-0 subtable ' - "and will not work in a few programs that may require " - "the table.", - ) - elif nonCharacterGlyphs: - yield FAIL, Message( - "kern-non-character-glyphs", - 'The following glyphs should not be used in the "kern" ' - 'table because they are not in the "cmap" table: %s' - % ", ".join(sorted(nonCharacterGlyphs)), - ) - else: - yield INFO, Message( - "kern-found", - "Only a few programs may require the kerning" - ' info that this font provides on its "kern" table.', - ) + nonCharacterGlyphs = set() + for kernTable in kern.kernTables: + if kernTable.format == 0: + for leftGlyph, rightGlyph in kernTable.kernTable.keys(): + if leftGlyph not in characterGlyphs: + nonCharacterGlyphs.add(leftGlyph) + if rightGlyph not in characterGlyphs: + nonCharacterGlyphs.add(rightGlyph) + if all(kernTable.format != 0 for kernTable in kern.kernTables): + yield WARN, Message( + "kern-unknown-format", + 'The "kern" table does not have any format-0 subtable ' + "and will not work in a few programs that may require " + "the table.", + ) + elif nonCharacterGlyphs: + yield FAIL, Message( + "kern-non-character-glyphs", + 'The following glyphs should not be used in the "kern" ' + 'table because they are not in the "cmap" table: %s' + % ", ".join(sorted(nonCharacterGlyphs)), + ) else: - yield PASS, 'Font does not declare an optional "kern" table.' + yield INFO, Message( + "kern-found", + "Only a few programs may require the kerning" + ' info that this font provides on its "kern" table.', + ) From e314b2d425d581ad58e3046ea68f1aaccfc2fbfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 03:03:21 -0300 Subject: [PATCH 39/46] simplify PASS results - opentype profile (layout) (issue #4612) --- Lib/fontbakery/checks/opentype/layout.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Lib/fontbakery/checks/opentype/layout.py b/Lib/fontbakery/checks/opentype/layout.py index 71e629befd..a229c8d1f7 100644 --- a/Lib/fontbakery/checks/opentype/layout.py +++ b/Lib/fontbakery/checks/opentype/layout.py @@ -1,7 +1,7 @@ from opentypespec.tags import FEATURE_TAGS, SCRIPT_TAGS, LANGUAGE_TAGS from fontbakery.callable import check -from fontbakery.status import PASS, FAIL +from fontbakery.status import FAIL from fontbakery.message import Message @@ -50,8 +50,6 @@ def com_google_fonts_check_layout_valid_feature_tags(ttFont): "The following invalid feature tags were found in the font: " + ", ".join(sorted(bad_tags)), ) - else: - yield PASS, "No invalid feature tags were found" def script_tags(ttFont): @@ -85,8 +83,6 @@ def com_google_fonts_check_layout_valid_script_tags(ttFont): "The following invalid script tags were found in the font: " + ", ".join(sorted(bad_tags)), ) - else: - yield PASS, "No invalid script tags were found" def language_tags(ttFont): @@ -121,5 +117,3 @@ def com_google_fonts_check_layout_valid_language_tags(ttFont): "The following invalid language tags were found in the font: " + ", ".join(sorted(bad_tags)), ) - else: - yield PASS, "No invalid language tags were found" From 7c715ad9c5292412e0992599cd9edc1a30b7e112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 03:03:54 -0300 Subject: [PATCH 40/46] simplify PASS results - opentype profile (loca) (issue #4612) --- Lib/fontbakery/checks/opentype/loca.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Lib/fontbakery/checks/opentype/loca.py b/Lib/fontbakery/checks/opentype/loca.py index 8b8ab3e03c..a4c53dd18d 100644 --- a/Lib/fontbakery/checks/opentype/loca.py +++ b/Lib/fontbakery/checks/opentype/loca.py @@ -1,5 +1,5 @@ from fontbakery.callable import check -from fontbakery.status import PASS, FAIL +from fontbakery.status import FAIL from fontbakery.message import Message @@ -21,5 +21,3 @@ def com_google_fonts_check_loca_maxp_num_glyphs(ttFont): yield FAIL, Message( "corrupt", 'Corrupt "loca" table or wrong numGlyphs in "maxp" table.' ) - else: - yield PASS, "'loca' table matches numGlyphs in 'maxp' table." From 14484898f37375c5262cd4be2c2d504443fa7343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 03:08:45 -0300 Subject: [PATCH 41/46] simplify PASS results - opentype profile (name) (issue #4612) --- Lib/fontbakery/checks/opentype/name.py | 65 ++++---------------------- tests/checks/opentype/name_test.py | 21 ++++----- 2 files changed, 20 insertions(+), 66 deletions(-) diff --git a/Lib/fontbakery/checks/opentype/name.py b/Lib/fontbakery/checks/opentype/name.py index 27d5bd45cf..fcdad85847 100644 --- a/Lib/fontbakery/checks/opentype/name.py +++ b/Lib/fontbakery/checks/opentype/name.py @@ -20,11 +20,9 @@ ) def com_adobe_fonts_check_name_empty_records(ttFont): """Check name table for empty records.""" - failed = False for name_record in ttFont["name"].names: name_string = name_record.toUnicode().strip() if len(name_string) == 0: - failed = True name_key = tuple( [ name_record.platformID, @@ -38,8 +36,6 @@ def com_adobe_fonts_check_name_empty_records(ttFont): f'"name" table record with key={name_key} is' f" empty and should be removed.", ) - if not failed: - yield PASS, ("No empty name table records found.") @check( @@ -54,29 +50,21 @@ def com_adobe_fonts_check_name_empty_records(ttFont): ) def com_google_fonts_check_name_no_copyright_on_description(ttFont): """Description strings in the name table must not contain copyright info.""" - failed = False for name in ttFont["name"].names: if ( "opyright" in name.string.decode(name.getEncoding()) and name.nameID == NameID.DESCRIPTION ): - failed = True - - if failed: - yield FAIL, Message( - "copyright-on-description", - f"Some namerecords with" - f" ID={NameID.DESCRIPTION} (NameID.DESCRIPTION)" - f" containing copyright info should be removed" - f" (perhaps these were added by a longstanding" - f" FontLab Studio 5.x bug that copied" - f" copyright notices to them.)", - ) - else: - yield PASS, ( - "Description strings in the name table" - " do not contain any copyright string." - ) + yield FAIL, Message( + "copyright-on-description", + f"Some namerecords with" + f" ID={NameID.DESCRIPTION} (NameID.DESCRIPTION)" + f" containing copyright info should be removed" + f" (perhaps these were added by a longstanding" + f" FontLab Studio 5.x bug that copied" + f" copyright notices to them.)", + ) + break def PANOSE_is_monospaced(panose): @@ -325,7 +313,6 @@ def com_google_fonts_check_name_match_familyname_fullfont(ttFont): name_table = ttFont["name"] names_compared = False # Used for knowing if at least one comparison was attempted - passed = True # Collect all the unique platformIDs, encodingIDs, and languageIDs # used in the font's name table. @@ -378,7 +365,6 @@ def com_google_fonts_check_name_match_familyname_fullfont(ttFont): f"{decode_error_msg_prefix} and nameID {family_name_id}" " failed to be decoded.", ) - passed = False continue try: @@ -391,7 +377,6 @@ def com_google_fonts_check_name_match_familyname_fullfont(ttFont): f"{decode_error_msg_prefix} and nameID {full_name_id}" " failed to be decoded.", ) - passed = False continue if not full_name.startswith(family_name): @@ -404,7 +389,6 @@ def com_google_fonts_check_name_match_familyname_fullfont(ttFont): f" languageID {lang_id}({lang_id:04X})," f" and nameID {family_name_id}.", ) - passed = False if not names_compared: yield FAIL, Message( @@ -416,8 +400,6 @@ def com_google_fonts_check_name_match_familyname_fullfont(ttFont): f" {NameID.TYPOGRAPHIC_FAMILY_NAME} (Typographic Family name)," f" or {NameID.WWS_FAMILY_NAME} (WWS Family name).", ) - elif passed: - yield PASS, "Full font name begins with the font family name." @check( @@ -457,8 +439,6 @@ def com_adobe_fonts_check_postscript_name(ttFont): f"PostScript name does not follow requirements:\n\n" f"{markdown_table(bad_entries)}", ) - else: - yield PASS, "PostScript name follows requirements." @check( @@ -550,8 +530,6 @@ def com_google_fonts_check_family_naming_recommendations(ttFont): f"\n" f"{table}", ) - else: - yield PASS, "Font follows the family naming recommendations." @check( @@ -576,22 +554,17 @@ def com_adobe_fonts_check_name_postscript_vs_cff(ttFont): ) return - passed = True cff_name = cff_names[0] for entry in ttFont["name"].names: if entry.nameID == NameID.POSTSCRIPT_NAME: postscript_name = entry.toUnicode() if postscript_name != cff_name: - passed = False yield FAIL, Message( "ps-cff-name-mismatch", f"Name table PostScript name '{postscript_name}' " f"does not match CFF table FontName '{cff_name}'.", ) - if passed: - yield PASS, ("Name table PostScript name matches CFF table FontName.") - @check( id="com.adobe.fonts/check/name/postscript_name_consistency", @@ -619,10 +592,6 @@ def com_adobe_fonts_check_name_postscript_name_consistency(ttFont): f" (PostScript name) are not consistent." f" Names found: {sorted(postscript_names)}.", ) - else: - yield PASS, ( - 'Entries in the "name" table for ID 6 (PostScript name) are consistent.' - ) @check( @@ -655,17 +624,13 @@ def com_adobe_fonts_check_family_max_4_fonts_per_family_name(ttFonts): names_set = set(names_list) family_names.extend(names_set) - passed = True counter = Counter(family_names) for family_name, count in counter.items(): if count > 4: - passed = False yield FAIL, Message( "too-many", f"Family '{family_name}' has {count} fonts" f" (should be 4 or fewer).", ) - if passed: - yield PASS, ("There were no more than 4 fonts per family name.") @check( @@ -747,8 +712,6 @@ def com_adobe_fonts_check_consistent_font_family_name(ttFonts): f"{''.join(detail_str_arr)}" ) yield FAIL, Message("inconsistent-family-name", msg) - else: - yield PASS, ("Font family names are consistent across the family.") @check( @@ -772,13 +735,11 @@ def get_name(nameID): if "Italic" not in style: yield SKIP, ("Font is not Italic.") else: - passed = True # Name ID 1 (Family Name) if "Italic" in get_name(NameID.FONT_FAMILY_NAME): yield FAIL, Message( "bad-familyname", "Name ID 1 (Family Name) must not contain 'Italic'." ) - passed = False # Name ID 2 (Subfamily Name) subfamily_name = get_name(NameID.FONT_SUBFAMILY_NAME) @@ -789,7 +750,6 @@ def get_name(nameID): " Only R/I/B/BI are allowed.\n" f"Got: '{subfamily_name}'.", ) - passed = False # Name ID 16 (Typographic Family Name) if get_name(NameID.TYPOGRAPHIC_FAMILY_NAME): @@ -798,7 +758,6 @@ def get_name(nameID): "bad-typographicfamilyname", "Name ID 16 (Typographic Family Name) must not contain 'Italic'.", ) - passed = False # Name ID 17 (Typographic Subfamily Name) if get_name(NameID.TYPOGRAPHIC_SUBFAMILY_NAME): @@ -807,7 +766,3 @@ def get_name(nameID): "bad-typographicsubfamilyname", "Name ID 17 (Typographic Subfamily Name) must contain 'Italic'.", ) - passed = False - - if passed: - yield PASS, ("All font names are good for Italic fonts.") diff --git a/tests/checks/opentype/name_test.py b/tests/checks/opentype/name_test.py index 7dae69af84..54a0d18c71 100644 --- a/tests/checks/opentype/name_test.py +++ b/tests/checks/opentype/name_test.py @@ -10,7 +10,9 @@ MacintoshEncodingID, MacintoshLanguageID, ) +from fontbakery.message import Message from fontbakery.status import INFO, WARN, PASS, FAIL, SKIP +from fontbakery.result import Subresult from fontbakery.codetesting import ( assert_PASS, assert_SKIP, @@ -219,8 +221,7 @@ def test_check_name_match_familyname_fullfont(): ttFont = TTFont(TEST_FILE("mada/Mada-Regular.ttf")) # So it must PASS the check: - msg = assert_PASS(check(ttFont)) - assert msg == "Full font name begins with the font family name." + assert_PASS(check(ttFont)) EXPECTED_NAME_STRING = "Mada" BAD_PREFIX = "bad-prefix" @@ -289,8 +290,7 @@ def test_check_name_match_familyname_fullfont(): # Run the check on a CJK font. The font's 'name' table contains # English-US (1033/0x0409) and Japanese (1041/0x0411) records. It should PASS. ttFont = TTFont(TEST_FILE("cjk/SourceHanSans-Regular.otf")) - msg = assert_PASS(check(ttFont)) - assert msg == "Full font name begins with the font family name." + assert_PASS(check(ttFont)) name_table = ttFont["name"] decode_error_msg_prefix = ( @@ -379,7 +379,7 @@ def name_test(value, expected, keyword=None): print("Test INFO: Exceeds max length (63)...") name_test("A" * 64, INFO, "bad-entries") - print("Test PASS: Does not exceeds max length...") + print("Test PASS: Does not exceed max length...") name_test("A" * 63, PASS) elif name.nameID == NameID.FONT_FAMILY_NAME: @@ -388,7 +388,7 @@ def name_test(value, expected, keyword=None): print("Test INFO: Exceeds max length (31)...") name_test("A" * 32, INFO, "bad-entries") - print("Test PASS: Does not exceeds max length...") + print("Test PASS: Does not exceed max length...") name_test("A" * 31, PASS) elif name.nameID == NameID.FONT_SUBFAMILY_NAME: @@ -397,7 +397,7 @@ def name_test(value, expected, keyword=None): print("Test INFO: Exceeds max length (31)...") name_test("A" * 32, INFO, "bad-entries") - print("Test PASS: Does not exceeds max length...") + print("Test PASS: Does not exceed max length...") name_test("A" * 31, PASS) elif name.nameID == NameID.TYPOGRAPHIC_FAMILY_NAME: @@ -406,7 +406,7 @@ def name_test(value, expected, keyword=None): print("Test INFO: Exceeds max length (31)...") name_test("A" * 32, INFO, "bad-entries") - print("Test PASS: Does not exceeds max length...") + print("Test PASS: Does not exceed max length...") name_test("A" * 31, PASS) elif name.nameID == NameID.TYPOGRAPHIC_SUBFAMILY_NAME: @@ -415,7 +415,7 @@ def name_test(value, expected, keyword=None): print("Test INFO: Exceeds max length (31)...") name_test("A" * 32, INFO, "bad-entries") - print("Test PASS: Does not exceeds max length...") + print("Test PASS: Does not exceed max length...") name_test("A" * 31, PASS) @@ -424,8 +424,7 @@ def test_check_name_postscript_vs_cff(): # Test a font that has matching names. Check should PASS. ttFont = TTFont(TEST_FILE("source-sans-pro/OTF/SourceSansPro-Bold.otf")) - msg = assert_PASS(check(ttFont)) - assert msg == "Name table PostScript name matches CFF table FontName." + assert_PASS(check(ttFont)) # Change the name-table string. Check should FAIL. other_name = "SomeOtherFontName" From 107417cfa589391bcca96f44a169a87f0af5ba27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 03:11:29 -0300 Subject: [PATCH 42/46] simplify PASS results - opentype profile (os2) (issue #4612) --- Lib/fontbakery/checks/opentype/os2.py | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/Lib/fontbakery/checks/opentype/os2.py b/Lib/fontbakery/checks/opentype/os2.py index 4055b10902..4b44e433dc 100644 --- a/Lib/fontbakery/checks/opentype/os2.py +++ b/Lib/fontbakery/checks/opentype/os2.py @@ -21,7 +21,6 @@ ) def com_google_fonts_check_family_panose_familytype(fonts: Iterable[Font], config): """Fonts have consistent PANOSE family type?""" - passed = True missing = [] familytypes = defaultdict(list) @@ -49,8 +48,6 @@ def com_google_fonts_check_family_panose_familytype(fonts: Iterable[Font], confi "The following PANOSE family types were found:\n\n" + show_inconsistencies(familytypes, config), ) - else: - yield PASS, "Fonts have consistent PANOSE family type." @check( @@ -194,11 +191,9 @@ def com_adobe_fonts_check_fsselection_matches_macstyle(ttFont): from fontbakery.constants import FsSelection, MacStyle - failed = False head_bold = (ttFont["head"].macStyle & MacStyle.BOLD) != 0 os2_bold = (ttFont["OS/2"].fsSelection & FsSelection.BOLD) != 0 if head_bold != os2_bold: - failed = True yield FAIL, Message( "fsselection-macstyle-bold", "The OS/2.fsSelection and head.macStyle bold settings do not match:\n\n" @@ -208,17 +203,12 @@ def com_adobe_fonts_check_fsselection_matches_macstyle(ttFont): head_italic = (ttFont["head"].macStyle & MacStyle.ITALIC) != 0 os2_italic = (ttFont["OS/2"].fsSelection & FsSelection.ITALIC) != 0 if head_italic != os2_italic: - failed = True yield FAIL, Message( "fsselection-macstyle-italic", "The OS/2.fsSelection and head.macStyle italic settings do not match.\n\n" f"* OS/2.fsSelection: ITALIC is {'not ' if not os2_italic else ''}set\n" f"* head.macStyle: ITALIC is {'not ' if not head_italic else ''}set", ) - if not failed: - yield PASS, ( - "The OS/2.fsSelection and head.macStyle bold and italic settings match." - ) @check( @@ -242,7 +232,6 @@ def com_adobe_fonts_check_family_bold_italic_unique_for_nameid1(RIBBI_ttFonts): from fontbakery.constants import FsSelection, NameID from fontbakery.utils import get_name_entry_strings - failed = False family_name_and_bold_italic = [] for ttFont in RIBBI_ttFonts: names_list = get_name_entry_strings(ttFont, NameID.FONT_FAMILY_NAME) @@ -266,10 +255,8 @@ def com_adobe_fonts_check_family_bold_italic_unique_for_nameid1(RIBBI_ttFonts): ) counter = Counter(family_name_and_bold_italic) - for (family_name, bold_italic), count in counter.items(): if count > 1: - failed = True yield FAIL, Message( "unique-fsselection", f"Family '{family_name}' has {count} fonts" @@ -277,11 +264,6 @@ def com_adobe_fonts_check_family_bold_italic_unique_for_nameid1(RIBBI_ttFonts): f" same OS/2.fsSelection bold & italic settings:" f" {bold_italic}", ) - if not failed: - yield PASS, ( - "The OS/2.fsSelection bold & italic settings were unique " - "within each compatible family group." - ) @check( @@ -326,8 +308,6 @@ def com_google_fonts_check_code_pages(ttFont): "No code pages defined in the OS/2 table" " ulCodePageRange1 and CodePageRange2 fields.", ) - else: - yield PASS, "At least one code page is defined." @check( @@ -364,8 +344,6 @@ def com_thetypefounders_check_vendor_id(config, ttFont): f"OS/2 VendorID is '{font_vendor_id}'," f" but should be '{config_vendor_id}'.", ) - else: - yield PASS, f"OS/2 VendorID '{font_vendor_id}' is correct." @check( From a2fcc6d765949c8bd271b8f1ca6965626b589a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 03:59:11 -0300 Subject: [PATCH 43/46] simplify PASS results - opentype profile (stat) (issue #4612) --- tests/checks/opentype/stat_test.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/checks/opentype/stat_test.py b/tests/checks/opentype/stat_test.py index 5b0450469e..13be2ceae4 100644 --- a/tests/checks/opentype/stat_test.py +++ b/tests/checks/opentype/stat_test.py @@ -21,8 +21,7 @@ def test_check_varfont_stat_axis_record_for_each_axis(): ttFont = TTFont(TEST_FILE("cabinvf/Cabin[wdth,wght].ttf")) # So the check must PASS - msg = assert_PASS(check(ttFont)) - assert msg == "STAT table has all necessary Axis Records." + assert_PASS(check(ttFont)) # We then remove its first Axis Record (`wdth`): ttFont["STAT"].table.DesignAxisRecord.Axis.pop(0) @@ -47,8 +46,7 @@ def test_check_stat_has_axis_value_tables(): # Our reference Cabin[wdth,wght].ttf variable font has Axis Value tables. # So the check must PASS. ttFont = TTFont(TEST_FILE("cabinvf/Cabin[wdth,wght].ttf")) - msg = assert_PASS(check(ttFont)) - assert msg == "STAT table has Axis Value tables." + assert_PASS(check(ttFont)) # Remove the 4th Axis Value table (index 3), belonging to 'Medium' weight. # The check should FAIL. @@ -66,8 +64,7 @@ def test_check_stat_has_axis_value_tables(): # Most of the Axis Value tables in Cabin[wdth,wght].ttf are format 1. # Now test with SourceSansVariable-Italic.ttf whose tables are mostly format 2. ttFont = TTFont(TEST_FILE("source-sans-pro/VAR/SourceSansVariable-Italic.ttf")) - msg = assert_PASS(check(ttFont)) - assert msg == "STAT table has Axis Value tables." + assert_PASS(check(ttFont)) # Remove the 2nd Axis Value table (index 1), belonging to 'Light' weight. # The check should FAIL. @@ -96,8 +93,7 @@ def test_check_stat_has_axis_value_tables(): f4avt.AxisValueRecord = [avr0, avr1] f4avt.AxisCount = len(f4avt.AxisValueRecord) ttFont["STAT"].table.AxisValueArray.AxisValue.append(f4avt) - msg = assert_PASS(check(ttFont)) - assert msg == "STAT table has Axis Value tables." + assert_PASS(check(ttFont)) # Now delete one of the AxisValueRecords of the just-added format 4 AxisValue table. # This should now FAIL since format 4 should contain at least 2 AxisValueRecords. From 1aed5e2d4e6b4a2b13b3ce9c54b86dc38da1d715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 05:02:48 -0300 Subject: [PATCH 44/46] simplify PASS results - ufo profile (issue #4612) --- tests/checks/ufo_sources_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/checks/ufo_sources_test.py b/tests/checks/ufo_sources_test.py index 64153cd060..8efa0824bd 100644 --- a/tests/checks/ufo_sources_test.py +++ b/tests/checks/ufo_sources_test.py @@ -43,7 +43,7 @@ def test_check_ufolint(empty_ufo_font): _, ufo_path = empty_ufo_font - assert assert_PASS(check(ufo_path)) == "ufolint passed the UFO source." + assert_PASS(check(ufo_path)) os.remove(os.path.join(ufo_path, "metainfo.plist")) msg = assert_results_contain(check(ufo_path), FAIL, "ufolint-fail") @@ -65,7 +65,7 @@ def test_check_required_fields(empty_ufo_font): ufo.info.capHeight = 700 ufo.info.familyName = "Test" - assert assert_PASS(check(ufo)) == "Required fields present." + assert_PASS(check(ufo)) def test_check_recommended_fields(empty_ufo_font): @@ -84,7 +84,7 @@ def test_check_recommended_fields(empty_ufo_font): ufo.info.copyright = "Test" ufo.info.openTypeOS2Panose = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - assert assert_PASS(check(ufo)) == "Recommended fields present." + assert_PASS(check(ufo)) def test_check_unnecessary_fields(empty_ufo_font): @@ -92,7 +92,7 @@ def test_check_unnecessary_fields(empty_ufo_font): ufo, _ = empty_ufo_font - assert assert_PASS(check(ufo)) == "Unnecessary fields omitted." + assert_PASS(check(ufo)) ufo.info.openTypeNameUniqueID = "aaa" ufo.info.openTypeNameVersion = "1.000" From 128fa7d381c400fc747b358adfe84073ee3bf0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 04:01:19 -0300 Subject: [PATCH 45/46] simplify PASS results - universal profile (issue #4612) --- tests/checks/universal_test.py | 72 ++++++++++++---------------------- 1 file changed, 24 insertions(+), 48 deletions(-) diff --git a/tests/checks/universal_test.py b/tests/checks/universal_test.py index 88dacff04e..c9011a7b76 100644 --- a/tests/checks/universal_test.py +++ b/tests/checks/universal_test.py @@ -94,18 +94,15 @@ def test_style_condition(): def test_check_valid_glyphnames(): """Glyph names are all valid?""" check = CheckTester("com.google.fonts/check/valid_glyphnames") - pass_msg = "Glyph names are all valid." # We start with a good font file: ttFont = TTFont(TEST_FILE("nunito/Nunito-Regular.ttf")) - message = assert_PASS(check(ttFont)) - assert message == pass_msg + assert_PASS(check(ttFont)) # There used to be a 31 char max-length limit. # This was considered good: ttFont.glyphOrder[2] = "a" * 31 - message = assert_PASS(check(ttFont)) - assert message == pass_msg + assert_PASS(check(ttFont)) # And this was considered bad: legacy_too_long = "a" * 32 @@ -149,8 +146,7 @@ def test_check_valid_glyphnames(): # Also test with CFF... ttFont = TTFont(TEST_FILE("source-sans-pro/OTF/SourceSansPro-Regular.otf")) - message = assert_PASS(check(ttFont)) - assert message == pass_msg + assert_PASS(check(ttFont)) # ... and CFF2 fonts cff2_skip_msg = "OpenType-CFF2 fonts with a format 3 post table" @@ -162,11 +158,9 @@ def test_check_valid_glyphnames(): def test_check_unique_glyphnames(): """Font contains unique glyph names?""" check = CheckTester("com.google.fonts/check/unique_glyphnames") - pass_msg = "Glyph names are all unique." ttFont = TTFont(TEST_FILE("nunito/Nunito-Regular.ttf")) - message = assert_PASS(check(ttFont)) - assert message == pass_msg + assert_PASS(check(ttFont)) # Fonttools renames duplicate glyphs with #1, #2, ... on load. # Code snippet from https://github.com/fonttools/fonttools/issues/149 @@ -199,8 +193,7 @@ def test_check_unique_glyphnames(): # Also test with CFF... ttFont = TTFont(TEST_FILE("source-sans-pro/OTF/SourceSansPro-Regular.otf")) - message = assert_PASS(check(ttFont)) - assert message == pass_msg + assert_PASS(check(ttFont)) # ... and CFF2 fonts cff2_skip_msg = "OpenType-CFF2 fonts with a format 3 post table" @@ -352,14 +345,12 @@ def test_check_fontbakery_version(mock_get, mock_installed): mock_response.json.return_value = {"info": {"version": latest_ver}} mock_get.return_value = mock_response mock_installed.return_value = {"fontbakery": MockDistribution(installed_ver)} - msg = assert_PASS(check(font)) - assert msg == "FontBakery is up-to-date." + assert_PASS(check(font)) # Test the case of installed version being newer than PyPI's version. installed_ver = "0.1.1" mock_installed.return_value = {"fontbakery": MockDistribution(installed_ver)} - msg = assert_PASS(check(font)) - assert msg == "FontBakery is up-to-date." + assert_PASS(check(font)) # Test the case of installed version being older than PyPI's version. installed_ver = "0.0.1" @@ -394,8 +385,7 @@ def test_check_fontbakery_version_live_apis(): # The check will make an actual request to PyPI.org, # and will query 'pip' to determine which version of 'fontbakery' is installed. # The check should PASS. - msg = assert_PASS(check(font)) - assert msg == "FontBakery is up-to-date." + assert_PASS(check(font)) def test_check_mandatory_glyphs(): @@ -405,7 +395,7 @@ def test_check_mandatory_glyphs(): check = CheckTester("com.google.fonts/check/mandatory_glyphs") ttFont = TTFont(TEST_FILE("nunito/Nunito-Regular.ttf")) - assert assert_PASS(check(ttFont)) == "OK" + assert_PASS(check(ttFont)) options = subset.Options() options.glyph_names = True # Preserve glyph names @@ -551,9 +541,7 @@ def editCmap(font, cp, name): editCmap(ttFont, 0x0020, "space") editCmap(ttFont, 0x00A0, "uni00A0") - assert assert_PASS(check(ttFont)) == ( - "Font has **AGL recommended** names for whitespace glyphs." - ) + assert_PASS(check(ttFont)) def test_check_whitespace_ink(): @@ -663,8 +651,7 @@ def test_check_required_tables(): cff2_font = TTFont(TEST_FILE("source-sans-pro/VAR/SourceSansVariable-Italic.otf")) # The TrueType font contains all required tables, so it must PASS the check. - msg = assert_PASS(check(ttFont), "with a good font...") - assert msg == "Font contains all required tables." + assert_PASS(check(ttFont), "with a good font...") # Here we confirm that the check also yields INFO with # a list of table tags specific to the font. @@ -673,8 +660,7 @@ def test_check_required_tables(): assert tag in msg # The OpenType-CFF font contains all required tables, so it must PASS the check. - msg = assert_PASS(check(cff_font), "with a good font...") - assert msg == "Font contains all required tables." + assert_PASS(check(cff_font), "with a good font...") # Here we confirm that the check also yields INFO with # a list of table tags specific to the OpenType-CFF font. @@ -688,8 +674,7 @@ def test_check_required_tables(): assert "CFF " in msg # The OpenType-CFF2 font contains all required tables, so it must PASS the check. - msg = assert_PASS(check(cff2_font), "with a good font...") - assert msg == "Font contains all required tables." + assert_PASS(check(cff2_font), "with a good font...") # Here we confirm that the check also yields INFO with # a list of table tags specific to the OpenType-CFF2 font. @@ -731,8 +716,7 @@ def test_check_required_tables(): del ttFont.reader.tables["fvar"] ttFont.reader.tables["STAT"] = "foo" - msg = assert_PASS(check(ttFont), "with STAT on a non-variable font...") - assert msg == "Font contains all required tables." + assert_PASS(check(ttFont), "with STAT on a non-variable font...") # and finally remove what we've just added: del ttFont.reader.tables["STAT"] @@ -874,8 +858,7 @@ def test_check_family_win_ascent_and_descent(mada_ttFonts): # Fix usWinAscent ttFont["OS/2"].usWinAscent = 880 - message = assert_PASS(check(ttFont)) - assert message == "OS/2 usWinAscent & usWinDescent values look good!" + assert_PASS(check(ttFont)) # Make usWinAscent too large ttFont["OS/2"].usWinAscent = 880 * 2 + 1 @@ -943,8 +926,7 @@ def test_check_os2_metrics_match_hhea(): def test_check_family_vertical_metrics(montserrat_ttFonts): check = CheckTester("com.google.fonts/check/family/vertical_metrics") - msg = assert_PASS(check(montserrat_ttFonts), "with multiple good fonts...") - assert msg == "Vertical metrics are the same across the family." + assert_PASS(check(montserrat_ttFonts), "with multiple good fonts...") montserrat_ttFonts[0]["OS/2"].sTypoAscender = 3333 montserrat_ttFonts[1]["OS/2"].usWinAscent = 4444 @@ -1015,7 +997,7 @@ def test_check_rupee(): ttFont = TTFont( TEST_FILE("indic-font-with-rupee-sign/NotoSerifDevanagari-Regular.ttf") ) - assert assert_PASS(check(ttFont)) == "Looks good!" + assert_PASS(check(ttFont)) # But this one lacks the glyph: ttFont = TTFont( @@ -1131,8 +1113,7 @@ def test_check_contour_count(montserrat_ttFonts): subsetter = subset.Subsetter() subsetter.populate(text="c") subsetter.subset(ttFont) - msg = assert_PASS(check(ttFont)) - assert msg == "All glyphs have the recommended amount of contours" + assert_PASS(check(ttFont)) # Now delete the 'cmap' table to trigger a FAIL del ttFont["cmap"] @@ -1201,8 +1182,7 @@ def test_check_freetype_rasterizer(): check = CheckTester("com.adobe.fonts/check/freetype_rasterizer") font = TEST_FILE("cabin/Cabin-Regular.ttf") - msg = assert_PASS(check(font), "with a good font...") - assert msg == "Font can be rasterized by FreeType." + assert_PASS(check(font), "with a good font...") font = TEST_FILE("ancho/AnchoGX.ttf") msg = assert_results_contain(check(font), FAIL, "freetype-crash") @@ -1214,8 +1194,7 @@ def test_check_freetype_rasterizer(): # Example that segfaults with 'freetype-py' version 2.4.0 font = TEST_FILE("source-sans-pro/VAR/SourceSansVariable-Italic.ttf") - msg = assert_PASS(check(font), "with a good font...") - assert msg == "Font can be rasterized by FreeType." + assert_PASS(check(font), "with a good font...") def test_check_sfnt_version(): @@ -1224,8 +1203,7 @@ def test_check_sfnt_version(): # Valid TrueType font; the check must PASS. ttFont = TTFont(TEST_FILE("cabinvf/Cabin[wdth,wght].ttf")) - msg = assert_PASS(check(ttFont)) - assert msg == "Font has the correct sfntVersion value." + assert_PASS(check(ttFont)) # Change the sfntVersion to an improper value for TrueType fonts. # The check should FAIL. @@ -1235,8 +1213,7 @@ def test_check_sfnt_version(): # Valid CFF font; the check must PASS. ttFont = TTFont(TEST_FILE("source-sans-pro/OTF/SourceSansPro-Bold.otf")) - msg = assert_PASS(check(ttFont)) - assert msg == "Font has the correct sfntVersion value." + assert_PASS(check(ttFont)) # Change the sfntVersion to an improper value for CFF fonts. The check should FAIL. ttFont.sfntVersion = "\x00\x01\x00\x00" @@ -1247,8 +1224,7 @@ def test_check_sfnt_version(): # Valid CFF2 font; the check must PASS. ttFont = TTFont(TEST_FILE("source-sans-pro/VAR/SourceSansVariable-Roman.otf")) - msg = assert_PASS(check(ttFont)) - assert msg == "Font has the correct sfntVersion value." + assert_PASS(check(ttFont)) # Change the sfntVersion to an improper value for CFF fonts. The check should FAIL. ttFont.sfntVersion = "\x00\x01\x00\x00" @@ -1375,7 +1351,7 @@ def test_check_STAT_in_statics(): stat.AxisValueArray.AxisValue = [stat.AxisValueArray.AxisValue[0]] # It should PASS now - assert assert_PASS(check(ttFont)) == "Looks good!" + assert_PASS(check(ttFont)) def test_check_alt_caron(): From 0533ace5ed0929eec6f505d1d4a4dc7a4b6ea67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Wed, 27 Mar 2024 04:03:11 -0300 Subject: [PATCH 46/46] we won't run code-tests on PASS messages anymore because PASS results should be kept simple, with a default generic message. (issue #4612) --- Lib/fontbakery/codetesting.py | 2 -- tests/checks/opentype/name_test.py | 7 ++++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Lib/fontbakery/codetesting.py b/Lib/fontbakery/codetesting.py index 0ead9974c7..7738efb866 100644 --- a/Lib/fontbakery/codetesting.py +++ b/Lib/fontbakery/codetesting.py @@ -188,10 +188,8 @@ def assert_PASS(check_results, reason="with a good font...", ignore_error=None): if ignore_error and subresult.status == ERROR: print(ignore_error) - return None else: assert subresult.status == PASS - return str(subresult.message) def assert_SKIP(check_results, reason=""): diff --git a/tests/checks/opentype/name_test.py b/tests/checks/opentype/name_test.py index 54a0d18c71..5bdd3c3669 100644 --- a/tests/checks/opentype/name_test.py +++ b/tests/checks/opentype/name_test.py @@ -333,7 +333,12 @@ def assert_name_table_check_result( # set value ttFont["name"].names[index].string = value.encode(name.getEncoding()) # run check - subresult = check(ttFont)[-1] + subresults = check(ttFont) + if subresults == []: + subresult = Subresult(PASS, Message("ok", "All looks good!")) + else: + subresult = subresults[-1] + status, message = subresult.status, subresult.message # restore value ttFont["name"].names[index].string = backup