diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dd9bb5097..5bc776f657 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ A more detailed list of changes is available in the corresponding milestones for ### Changes to existing checks #### On the Open Type Profile - **[com.google.fonts/check/layout_valid_feature_tags]:** Updated the check to allow valid private-use feature tags. (issue #4544) + - **[com.google.fonts/check/mac_style]:** Skip if font style can not be determined. (issue #4349) ## 0.12.0a2 (2024-Feb-21) diff --git a/Lib/fontbakery/checks/opentype/head.py b/Lib/fontbakery/checks/opentype/head.py index 7cf9922ee8..6bdf723cc9 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, PASS, WARN, SKIP from fontbakery.message import Message from fontbakery.constants import NameID @@ -191,6 +191,10 @@ def com_google_fonts_check_mac_style(font): from fontbakery.utils import check_bit_entry from fontbakery.constants import MacStyle + if font.style is None: + yield SKIP, "Font style could not be determined." + return + # Checking macStyle ITALIC bit: expected = "Italic" in font.style yield check_bit_entry( diff --git a/tests/checks/opentype/head_test.py b/tests/checks/opentype/head_test.py index a31337e7a2..649dab8d1c 100644 --- a/tests/checks/opentype/head_test.py +++ b/tests/checks/opentype/head_test.py @@ -1,9 +1,10 @@ from fontTools.ttLib import TTFont import pytest -from fontbakery.status import WARN, FAIL, PASS +from fontbakery.status import WARN, FAIL, PASS, SKIP from fontbakery.codetesting import ( assert_PASS, + assert_SKIP, assert_results_contain, CheckTester, TEST_FILE, @@ -194,6 +195,7 @@ def test_check_mac_style(): [MacStyle.BOLD, "Bold", PASS], [MacStyle.BOLD, "Thin", "bad-BOLD"], [MacStyle.BOLD | MacStyle.ITALIC, "BoldItalic", PASS], + [0, None, SKIP], ] for macStyle_value, style, expected in test_cases: @@ -204,6 +206,11 @@ def test_check_mac_style(): check(MockFont(ttFont=ttFont, style=style)), "with macStyle:{macStyle_value} style:{style}...", ) + elif expected == SKIP: + assert_SKIP( + check(MockFont(ttFont=ttFont, style=style)), + "with macStyle:{macStyle_value} style:{style}...", + ) else: assert_results_contain( check(MockFont(ttFont=ttFont, style=style)),