Skip to content

Commit

Permalink
com.google.fonts/check/mac_style: Skip if font.style is None
Browse files Browse the repository at this point in the history
If font.style is None, the test currently errors/

Related to #4349, but not
a complete fix.
  • Loading branch information
khaledhosny committed Feb 25, 2024
1 parent 546808a commit 388a910
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion Lib/fontbakery/checks/opentype/head.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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(
Expand Down
9 changes: 8 additions & 1 deletion tests/checks/opentype/head_test.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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:
Expand All @@ -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)),
Expand Down

0 comments on commit 388a910

Please sign in to comment.