Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate colorfont_tables check back to Google Fonts profile #4949

Merged
merged 1 commit into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Lib/fontbakery/legacy_checkids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion Lib/fontbakery/profiles/adobefonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion Lib/fontbakery/profiles/fontbureau.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions Lib/fontbakery/profiles/googlefonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion Lib/fontbakery/profiles/microsoft.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion Lib/fontbakery/profiles/typenetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", # <
Expand Down
1 change: 0 additions & 1 deletion Lib/fontbakery/profiles/universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
65 changes: 1 addition & 64 deletions tests/test_checks_color.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from fontTools.ttLib import newTable, TTFont
from fontTools.ttLib import TTFont

from conftest import check_id
from fontbakery.codetesting import (
Expand All @@ -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"""
Expand Down
72 changes: 72 additions & 0 deletions tests/test_checks_googlefonts_colorfont_tables.py
Original file line number Diff line number Diff line change
@@ -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.")
Loading