diff --git a/.gitignore b/.gitignore index 18b8ba60ca..9101eabf97 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ htmlcov _version.py venv +fontbakery-venv docs/_build .eggs .tox diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f73ee62a9..e0349c35aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ A more detailed list of changes is available in the corresponding milestones for ## Upcoming release: 0.13.1 (2025-Jan-??) - ... +### Changes to existing checks +### On the OpenType Profile + - **[opentype/slant_direction]:** SKIP instead of ERROR if a font does not contain 'H' (PR #4969) + ## 0.13.0 (2025-Jan-10) ### Stable release notes diff --git a/Lib/fontbakery/checks/opentype/slant_direction.py b/Lib/fontbakery/checks/opentype/slant_direction.py index 4bd1c01225..03d61e0f62 100644 --- a/Lib/fontbakery/checks/opentype/slant_direction.py +++ b/Lib/fontbakery/checks/opentype/slant_direction.py @@ -1,6 +1,10 @@ -from fontbakery.prelude import check, condition, Message, FAIL, PASS +from fontbakery.prelude import Message, check, condition +from fontbakery.status import FAIL, PASS, SKIP from fontbakery.testable import Font +# Reference codepoint to use to determine slant angle. +REFERENCE = "H" + @condition(Font) def uharfbuzz_blob(font): @@ -33,10 +37,19 @@ def check_slant_direction(ttFont, uharfbuzz_blob): yield PASS, "Font has no slnt axis" return + if ord(REFERENCE) not in ttFont.getBestCmap(): + yield SKIP, Message( + "no-reference-glyph", + f"This check uses '{REFERENCE}' as a reference codepoint to " + "determine slant direction, but it is not present in this font, " + "and so the slant direction cannot be checked.", + ) + return + hb_face = hb.Face(uharfbuzz_blob) hb_font = hb.Font(hb_face) buf = hb.Buffer() - buf.add_str("H") + buf.add_str(REFERENCE) features = {"kern": True, "liga": True} hb.shape(hb_font, buf, features) diff --git a/README.md b/README.md index 6be44bf732..8af6068701 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,12 @@ For video introductions, see the [TypeCon 2018](https://www.youtube.com/watch?v= Font Bakery has an active community of contributors from foundries around the world, including Adobe Fonts, Dalton Maag, Type Network, and Google Fonts. Font Bakery is not an official Google project, and Google provides no support for it. -However, throughout 2018-2024 a project maintainer, Felipe CorrĂȘa da Silva Sanches ([@felipesanches](https://github.com/felipesanches)), is commissioned by the Google Fonts team to maintain it. +However, throughout 2018-2025 a project maintainer, Felipe CorrĂȘa da Silva Sanches ([@felipesanches](https://github.com/felipesanches)), is commissioned by the Google Fonts team to maintain it. The original software architecture (and maintenance of it) is by Lasse Fister ([@graphicore](https://github.com/graphicore)). ## Run Font Bakery automatically on Github Actions -Simon Cozens prepared a [template git repo](https://github.com/googlefonts/Unified-Font-Repository) that makes it easy to build, check and proof fonts. He's also prepared a nice [1 minute video](https://twitter.com/simoncozens/status/1405267459028905984) showcasing it. +Simon Cozens prepared a [template git repo](https://github.com/googlefonts/Unified-Font-Repository) that makes it easy to build, check and proof fonts. He's also prepared a nice [1 minute video](https://youtu.be/OyCOnY9BP94) showcasing it. ## License diff --git a/pyproject.toml b/pyproject.toml index 34e6dbe628..b4f3965292 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ dependencies = [ "cmarkgfm >= 0.4", "defcon", "dehinter >= 3.1.0", # 3.1.0 added dehinter.font.hint function - "fontTools[ufo] >= 4.46.0", + "fontTools[ufo] >= 4.47.0", # varLib.interpolatableHelpers.InterpolatableProblem "freetype-py < 2.4.0", # see: https://github.com/fonttools/fontbakery/issues/4143 "Jinja2 >= 3.0.0", # issue #4717 "munkres", diff --git a/tests/test_checks_opentype_varfont_family_axis_ranges.py b/tests/test_checks_opentype_varfont_family_axis_ranges.py index daed9cbca9..a814bf79be 100644 --- a/tests/test_checks_opentype_varfont_family_axis_ranges.py +++ b/tests/test_checks_opentype_varfont_family_axis_ranges.py @@ -1,7 +1,8 @@ from fontTools.ttLib import TTFont from conftest import check_id -from fontbakery.status import FAIL +from fontbakery.status import FAIL, SKIP +from fontbakery.checks.opentype.slant_direction import REFERENCE from fontbakery.codetesting import ( assert_PASS, assert_results_contain, @@ -35,3 +36,19 @@ def test_check_slant_direction(check): font = TEST_FILE("slant_direction/Cairo_wrong_slnt_axis.ttf") assert_results_contain(check(font), FAIL, "positive-value-for-clockwise-lean") + + +@check_id("opentype/slant_direction") +def test_check_slant_direction_missing(check, tmp_path): + """Check that the slant direction check handles the case where its reference + codepoint is not present.""" + + missing_codepoint = tmp_path / "MissingCodepoint.ttf" + + # Remove the reference codepoint from a TTF that would otherwise PASS. + ttf = TTFont(TEST_FILE("slant_direction/Cairo_correct_slnt_axis.ttf"), lazy=False) + for subtable in ttf["cmap"].tables: + subtable.cmap.pop(ord(REFERENCE), None) + ttf.save(missing_codepoint) + + assert_results_contain(check(str(missing_codepoint)), SKIP, "no-reference-glyph")