diff --git a/CHANGELOG.md b/CHANGELOG.md index cb5eb5432f..729ea3912d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ A more detailed list of changes is available in the corresponding milestones for - **[STAT/ital_axis]**: Replaces the old checks (**opentype/italic_axis_in_stat**, **opentype/italic_axis_in_stat_is_boolean** and **opentype/italic_axis_last**) from the same profile (issue #4865) ### Migration of checks +#### Moved from Universal to Google Fonts profile + - **[[colorfont_tables]]: Renamed and moved back to **googlefonts/color_fonts** based on feedback from @khaledhosny (issue #4945) + #### Moved from Google Fonts to Universal profile - **[googlefonts/varfont/duplicate_instance_names]**: Renamed to **varfont/duplicate_instance_names** (PR #4937) - **[googlefonts/varfont/bold_wght_coord]**: Renamed to **varfont/bold_wght_coord** (PR #4938) diff --git a/Lib/fontbakery/checks/colorfont_tables.py b/Lib/fontbakery/checks/vendorspecific/googlefonts/colorfont_tables.py similarity index 98% rename from Lib/fontbakery/checks/colorfont_tables.py rename to Lib/fontbakery/checks/vendorspecific/googlefonts/colorfont_tables.py index 72ae31bc54..3e5d1b1703 100644 --- a/Lib/fontbakery/checks/colorfont_tables.py +++ b/Lib/fontbakery/checks/vendorspecific/googlefonts/colorfont_tables.py @@ -2,7 +2,7 @@ @check( - id="colorfont_tables", + id="googlefonts/colorfont_tables", rationale=""" COLR v0 fonts are widely supported in most browsers so they do not require an SVG color table. However, some environments (e.g. Safari, Adobe apps) diff --git a/Lib/fontbakery/legacy_checkids.py b/Lib/fontbakery/legacy_checkids.py index 6855d9eb9a..1ccea78df6 100644 --- a/Lib/fontbakery/legacy_checkids.py +++ b/Lib/fontbakery/legacy_checkids.py @@ -16,7 +16,6 @@ "com.google.fonts/check/cjk_not_enough_glyphs": "cjk_not_enough_glyphs", "com.google.fonts/check/cmap/format_12": "cmap/format_12", "com.google.fonts/check/color_cpal_brightness": "color_cpal_brightness", - "com.google.fonts/check/colorfont_tables": "colorfont_tables", "com.google.fonts/check/contour_count": "contour_count", "com.google.fonts/check/family/control_chars": "control_chars", "com.google.fonts/check/designspace_has_consistent_codepoints": "designspace_has_consistent_codepoints", @@ -47,6 +46,7 @@ "com.google.fonts/check/canonical_filename": "googlefonts/canonical_filename", "com.google.fonts/check/cjk_vertical_metrics": "googlefonts/cjk_vertical_metrics", "com.google.fonts/check/cjk_vertical_metrics_regressions": "googlefonts/cjk_vertical_metrics_regressions", + "com.google.fonts/check/colorfont_tables": "googlefonts/colorfont_tables", "com.google.fonts/check/description/broken_links": "googlefonts/description/broken_links", "com.google.fonts/check/description/eof_linebreak": "googlefonts/description/eof_linebreak", "com.google.fonts/check/description/family_update": "googlefonts/description/family_update", diff --git a/Lib/fontbakery/profiles/adobefonts.py b/Lib/fontbakery/profiles/adobefonts.py index c7060268b6..49ced3b1ca 100644 --- a/Lib/fontbakery/profiles/adobefonts.py +++ b/Lib/fontbakery/profiles/adobefonts.py @@ -48,7 +48,6 @@ "cjk_chws_feature", # was temporarily removed "cjk_not_enough_glyphs", "color_cpal_brightness", - "colorfont_tables", "contour_count", # was temporarily removed "control_chars", "epar", diff --git a/Lib/fontbakery/profiles/fontbureau.py b/Lib/fontbakery/profiles/fontbureau.py index bb095e3367..485c465954 100644 --- a/Lib/fontbakery/profiles/fontbureau.py +++ b/Lib/fontbakery/profiles/fontbureau.py @@ -8,7 +8,6 @@ "cjk_not_enough_glyphs", "cmap/format_12", "color_cpal_brightness", - "colorfont_tables", "control_chars", "empty_glyph_on_gid1_for_colrv0", "empty_letters", diff --git a/Lib/fontbakery/profiles/googlefonts.py b/Lib/fontbakery/profiles/googlefonts.py index 1ef7908feb..19551f5838 100644 --- a/Lib/fontbakery/profiles/googlefonts.py +++ b/Lib/fontbakery/profiles/googlefonts.py @@ -123,6 +123,7 @@ "googlefonts/canonical_filename", "googlefonts/cjk_vertical_metrics", "googlefonts/cjk_vertical_metrics_regressions", + "googlefonts/colorfont_tables", "googlefonts/font_names", "googlefonts/fstype", "googlefonts/fvar_instances", diff --git a/Lib/fontbakery/profiles/microsoft.py b/Lib/fontbakery/profiles/microsoft.py index 3254e3bc8c..f75ea262c7 100644 --- a/Lib/fontbakery/profiles/microsoft.py +++ b/Lib/fontbakery/profiles/microsoft.py @@ -15,7 +15,6 @@ "cjk_not_enough_glyphs", "cmap/format_12", "color_cpal_brightness", - "colorfont_tables", "control_chars", "designspace_has_consistent_codepoints", "designspace_has_consistent_glyphset", diff --git a/Lib/fontbakery/profiles/typenetwork.py b/Lib/fontbakery/profiles/typenetwork.py index cce2ac6212..d832eb1684 100644 --- a/Lib/fontbakery/profiles/typenetwork.py +++ b/Lib/fontbakery/profiles/typenetwork.py @@ -13,7 +13,6 @@ "cjk_chws_feature", "cjk_not_enough_glyphs", "color_cpal_brightness", # Color fonts check. - "colorfont_tables", # Color fonts check. "designspace_has_consistent_codepoints", # < TypeNetwork doesn’t check designspace files. "designspace_has_consistent_glyphset", # < "designspace_has_consistent_groups", # < diff --git a/Lib/fontbakery/profiles/universal.py b/Lib/fontbakery/profiles/universal.py index 21d0f11d14..d4c03fd900 100644 --- a/Lib/fontbakery/profiles/universal.py +++ b/Lib/fontbakery/profiles/universal.py @@ -31,7 +31,6 @@ "cjk_not_enough_glyphs", "cmap/format_12", "color_cpal_brightness", - "colorfont_tables", "contour_count", "control_chars", "empty_glyph_on_gid1_for_colrv0", diff --git a/tests/test_checks_color.py b/tests/test_checks_color.py index 94038faa0d..d3b9091a70 100644 --- a/tests/test_checks_color.py +++ b/tests/test_checks_color.py @@ -1,4 +1,4 @@ -from fontTools.ttLib import newTable, TTFont +from fontTools.ttLib import TTFont from conftest import check_id from fontbakery.codetesting import ( @@ -9,69 +9,6 @@ from fontbakery.status import FAIL, WARN -@check_id("colorfont_tables") -def test_check_colorfont_tables(check): - """Ensure font has the expected color font tables.""" - - ttFont = TTFont(TEST_FILE("color_fonts/noto-glyf_colr_1.ttf")) - assert "SVG " not in ttFont.keys() - assert "COLR" in ttFont.keys() - assert ttFont["COLR"].version == 1 - # Check colr v1 static font has an svg table (since v1 isn't yet broadly supported). - # Will fail since font doesn't have one. - assert_results_contain( - check(ttFont), FAIL, "add-svg", "with a static colr v1 font lacking SVG table" - ) - - # Fake a variable font by adding an fvar table. - ttFont["fvar"] = newTable("fvar") - assert "fvar" in ttFont.keys() - - # SVG does not support OpenType Variations - assert_PASS(check(ttFont), "with a variable color font without SVG table") - - # Fake an SVG table: - ttFont["SVG "] = newTable("SVG ") - assert "SVG " in ttFont.keys() - - assert_results_contain( - check(ttFont), FAIL, "variable-svg", "with a variable color font with SVG table" - ) - - # Make it a static again: - del ttFont["fvar"] - assert "fvar" not in ttFont.keys() - - assert "SVG " in ttFont.keys() - assert "COLR" in ttFont.keys() - assert ttFont["COLR"].version == 1 - assert_PASS(check(ttFont), "with a static colr v1 font containing both tables.") - - # Now downgrade to colr table to v0: - ttFont["COLR"].version = 0 - assert "SVG " in ttFont.keys() - assert_results_contain( - check(ttFont), - FAIL, - "drop-svg", - "with a font which should not have an SVG table", - ) - - # Delete colr table and keep SVG: - del ttFont["COLR"] - assert "SVG " in ttFont.keys() - assert "COLR" not in ttFont.keys() - assert_results_contain( - check(ttFont), FAIL, "add-colr", "with a font which should have a COLR table" - ) - - # Finally delete both color font tables - del ttFont["SVG "] - assert "SVG " not in ttFont.keys() - assert "COLR" not in ttFont.keys() - assert_PASS(check(ttFont), "with a good font without SVG or COLR tables.") - - @check_id("color_cpal_brightness") def test_check_color_cpal_brightness(check): """Color layers should have a minimum brightness""" diff --git a/tests/test_checks_googlefonts_colorfont_tables.py b/tests/test_checks_googlefonts_colorfont_tables.py new file mode 100644 index 0000000000..8a21d000f7 --- /dev/null +++ b/tests/test_checks_googlefonts_colorfont_tables.py @@ -0,0 +1,72 @@ +from fontTools.ttLib import newTable, TTFont + +from conftest import check_id +from fontbakery.codetesting import ( + assert_PASS, + assert_results_contain, + TEST_FILE, +) +from fontbakery.status import FAIL + + +@check_id("googlefonts/colorfont_tables") +def test_check_colorfont_tables(check): + """Ensure font has the expected color font tables.""" + + ttFont = TTFont(TEST_FILE("color_fonts/noto-glyf_colr_1.ttf")) + assert "SVG " not in ttFont.keys() + assert "COLR" in ttFont.keys() + assert ttFont["COLR"].version == 1 + # Check colr v1 static font has an svg table (since v1 isn't yet broadly supported). + # Will fail since font doesn't have one. + assert_results_contain( + check(ttFont), FAIL, "add-svg", "with a static colr v1 font lacking SVG table" + ) + + # Fake a variable font by adding an fvar table. + ttFont["fvar"] = newTable("fvar") + assert "fvar" in ttFont.keys() + + # SVG does not support OpenType Variations + assert_PASS(check(ttFont), "with a variable color font without SVG table") + + # Fake an SVG table: + ttFont["SVG "] = newTable("SVG ") + assert "SVG " in ttFont.keys() + + assert_results_contain( + check(ttFont), FAIL, "variable-svg", "with a variable color font with SVG table" + ) + + # Make it a static again: + del ttFont["fvar"] + assert "fvar" not in ttFont.keys() + + assert "SVG " in ttFont.keys() + assert "COLR" in ttFont.keys() + assert ttFont["COLR"].version == 1 + assert_PASS(check(ttFont), "with a static colr v1 font containing both tables.") + + # Now downgrade to colr table to v0: + ttFont["COLR"].version = 0 + assert "SVG " in ttFont.keys() + assert_results_contain( + check(ttFont), + FAIL, + "drop-svg", + "with a font which should not have an SVG table", + ) + + # Delete colr table and keep SVG: + del ttFont["COLR"] + assert "SVG " in ttFont.keys() + assert "COLR" not in ttFont.keys() + assert_results_contain( + check(ttFont), FAIL, "add-colr", "with a font which should have a COLR table" + ) + + # Finally delete both color font tables + del ttFont["SVG "] + assert "SVG " not in ttFont.keys() + assert "COLR" not in ttFont.keys() + assert_PASS(check(ttFont), "with a good font without SVG or COLR tables.")