Skip to content

Commit

Permalink
Override freetype_rasterizer to make it mandatory for Google Fonts
Browse files Browse the repository at this point in the history
At 8bf12c8, I noticed that it would be wise for the Google Fonts profile to also override the freetype_rasterizer check from SKIP (if freetype dependency is not installed) to a FAIL, just like Adobe Fonts does.

We will also need to setup the google/fonts CI rules so that we install freetype before running fontbakery on font PRs.

The check, on the Universal Profile, emits a SKIP by default because it is considered an optional check. But I think it should be mandatory for Google Fonts.
(issue #3871)
  • Loading branch information
felipesanches committed Aug 22, 2022
1 parent 76d09f3 commit d25afae
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ A more detailed list of changes is available in the corresponding milestones for
- **[com.google.fonts/check/varfont_weight_instances]:** Removed due to new `fvar_instances` check (PR #3800)
- **[com.google.fonts/check/varfont_instance_coordinates]:** Removed due to new `fvar_instances` check (PR #3800)
- **[com.google.fonts/check/varfont_instance_names]:** Removed due to new `fvar_instances` check (PR #3800)
- **[com.adobe.fonts/check/freetype_rasterizer]:** Override this check to make it mandatory for Google Fonts, emitting a FAIL if freetype is not installed, instead of silently skipping. (issue #3871)

### BugFixes
- **[com.google.fonts/check/unreachable_glyphs]:** Fix crash by adding support for color-font legacy COLR v0 format. (issue #3850)
Expand Down
23 changes: 21 additions & 2 deletions Lib/fontbakery/profiles/googlefonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
from fontbakery.status import INFO, WARN, ERROR, SKIP, PASS, FAIL
from fontbakery.section import Section
from fontbakery.callable import check, disable
from fontbakery.utils import bullet_list, filesize_formatting, markdown_table
from fontbakery.message import Message
from fontbakery.utils import (add_check_overrides,
bullet_list,
filesize_formatting,
markdown_table)
from fontbakery.message import Message, KEEP_ORIGINAL_MESSAGE
from fontbakery.fonts_profile import profile_factory
from fontbakery.constants import (NameID,
PlatformID,
Expand All @@ -29,6 +32,10 @@
}
}

OVERRIDDEN_CHECKS = [
"com.adobe.fonts/check/freetype_rasterizer",
]

METADATA_CHECKS = [
'com.google.fonts/check/metadata/parses',
'com.google.fonts/check/metadata/unknown_designer',
Expand Down Expand Up @@ -6177,4 +6184,16 @@ def check_skip_filter(checkid, font=None, **iterargs):

profile.check_skip_filter = check_skip_filter
profile.auto_register(globals())

profile.check_log_override(
# From universal.py
"com.adobe.fonts/check/freetype_rasterizer",
overrides=(("freetype-not-installed", FAIL, KEEP_ORIGINAL_MESSAGE),),
reason="For Google Fonts, this check is very important and should never be skipped.",
)

GOOGLEFONTS_PROFILE_CHECKS = add_check_overrides(
GOOGLEFONTS_PROFILE_CHECKS, profile.profile_tag, OVERRIDDEN_CHECKS
)

profile.test_expected_checks(GOOGLEFONTS_PROFILE_CHECKS, exclusive=True)
16 changes: 16 additions & 0 deletions tests/profiles/googlefonts_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from fontbakery.profiles.googlefonts_conditions import expected_font_names
import pytest
import os
from unittest.mock import patch
from fontTools.ttLib import TTFont

from fontbakery.checkrunner import (DEBUG, INFO, WARN, ERROR,
Expand Down Expand Up @@ -4197,3 +4198,18 @@ def test_check_STAT(fps, new_stat, result):
assert_results_contain(check(ttFont, {"expected_font_names": expected}),
FAIL, 'bad-axis-values',
'with a bad font')


OVERRIDE_SUFFIX = ":googlefonts"

@patch("freetype.Face", side_effect=ImportError)
def test_check_override_freetype_rasterizer(mock_import_error):
"""Check that overridden test yields FAIL rather than SKIP."""
check = CheckTester(
googlefonts_profile,
f"com.adobe.fonts/check/freetype_rasterizer{OVERRIDE_SUFFIX}",
)

font = TEST_FILE("cabin/Cabin-Regular.ttf")
msg = assert_results_contain(check(font), FAIL, "freetype-not-installed")
assert "FreeType is not available" in msg

0 comments on commit d25afae

Please sign in to comment.