Skip to content

Commit

Permalink
Merge branch 'main' into fix_segment_vf_collection
Browse files Browse the repository at this point in the history
  • Loading branch information
benkiel authored Jan 13, 2025
2 parents 1df308a + 7b75e1f commit 173f5b8
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
htmlcov
_version.py
venv
fontbakery-venv
docs/_build
.eggs
.tox
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 15 additions & 2 deletions Lib/fontbakery/checks/opentype/slant_direction.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 18 additions & 1 deletion tests/test_checks_opentype_varfont_family_axis_ranges.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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")

0 comments on commit 173f5b8

Please sign in to comment.