Skip to content

Commit

Permalink
Move varfont/duplicate_instance_names to Universal profile
Browse files Browse the repository at this point in the history
googlefonts/varfont/duplicate_instance_names from Google Fonts profile.
Renamed to varfont/duplicate_instance_names

(PR #4937)
  • Loading branch information
felipesanches committed Dec 27, 2024
1 parent c3ea61f commit 2aad872
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 45 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ A more detailed list of changes is available in the corresponding milestones for
- to generate documentation
- to implement a backwards compatibility mechanism

### Migration of checks
#### Moved from Google Fonts to Universal profile
- **[googlefonts/varfont/duplicate_instance_names]**: Renamed to **varfont/duplicate_instance_names** (PR #4937)


### Deprecated checks
#### On the Universal Profile
- **[kerning_for_non_ligated_sequences]**: "Is there kerning info for non-ligated sequences?" (issue #2954 / https://github.com/simoncozens/fontspector/commit/eaa52447ddc4a42e26b6430841a43026870d8a48)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@


@check(
id="googlefonts/varfont/duplicate_instance_names",
id="varfont/duplicate_instance_names",
rationale="""
This check's purpose is to detect duplicate named instances names in a
given variable font.
Repeating instance names may be the result of instances for several VF axes
defined in `fvar`, but since currently only weight+italic tokens are allowed
in instance names as per GF specs, they ended up repeating.
Instead, only a base set of fonts for the most default representation of the
defined in `fvar`, but in some setups only weight+italic tokens are used
in instance names, so they end up repeating.
Only a base set of fonts for the most default representation of the
family can be defined through instances in the `fvar` table, all other
instances will have to be left to access through the `STAT` table.
""",
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 @@ -142,7 +142,6 @@
"com.google.fonts/check/unitsperem_strict": "googlefonts/unitsperem",
"com.google.fonts/check/os2/use_typo_metrics": "googlefonts/use_typo_metrics",
"com.google.fonts/check/varfont/bold_wght_coord": "googlefonts/varfont/bold_wght_coord",
"com.google.fonts/check/varfont_duplicate_instance_names": "googlefonts/varfont/duplicate_instance_names",
"com.google.fonts/check/varfont/generate_static": "googlefonts/varfont/generate_static",
"com.google.fonts/check/varfont/has_HVAR": "googlefonts/varfont/has_HVAR",
"com.google.fonts/check/vendor_id": "googlefonts/vendor_id",
Expand Down Expand Up @@ -327,6 +326,7 @@
"com.google.fonts/check/valid_glyphnames": "valid_glyphnames",
"com.google.fonts/check/varfont/consistent_axes": "varfont/consistent_axes",
"com.google.fonts/check/varfont/duplexed_axis_reflow": "varfont/duplexed_axis_reflow",
"com.google.fonts/check/varfont/duplicate_instance_names": "varfont/duplicate_instance_names",
"com.google.fonts/check/varfont/instances_in_order": "varfont/instances_in_order",
"com.google.fonts/check/varfont/unsupported_axes": "varfont/unsupported_axes",
"com.microsoft/check/vtt_volt_data": "vtt_volt_data",
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 @@ -98,7 +98,6 @@
"adobefonts/STAT_strings",
],
"Google Fonts": [
"googlefonts/varfont/duplicate_instance_names",
"googlefonts/varfont/bold_wght_coord",
],
},
Expand Down
1 change: 1 addition & 0 deletions Lib/fontbakery/profiles/fontbureau.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"typographic_family_name",
"varfont/consistent_axes",
"varfont/duplexed_axis_reflow",
"varfont/duplicate_instance_names",
"varfont/instances_in_order",
"varfont/unsupported_axes",
"vtt_volt_data", # very similar to vttclean, may be a good idea to merge them.
Expand Down
1 change: 0 additions & 1 deletion Lib/fontbakery/profiles/googlefonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@
"googlefonts/unitsperem",
"googlefonts/use_typo_metrics",
"googlefonts/varfont/bold_wght_coord",
"googlefonts/varfont/duplicate_instance_names",
"googlefonts/varfont/generate_static",
"googlefonts/varfont/has_HVAR",
"googlefonts/vendor_id",
Expand Down
1 change: 1 addition & 0 deletions Lib/fontbakery/profiles/microsoft.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"unwanted_aat_tables",
"varfont/consistent_axes",
"varfont/duplexed_axis_reflow",
"varfont/duplicate_instance_names",
"varfont/instances_in_order",
"varfont/unsupported_axes",
"vttclean", # very similar to vtt_volt_data, may be a good idea to merge them.
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 @@ -72,7 +72,6 @@
"Google Fonts": [
"googlefonts/family/equal_codepoint_coverage",
"googlefonts/varfont/bold_wght_coord",
"googlefonts/varfont/duplicate_instance_names",
"googlefonts/STAT/axis_order",
],
"Outline Checks": [
Expand Down
1 change: 1 addition & 0 deletions Lib/fontbakery/profiles/universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"valid_glyphnames",
"varfont/consistent_axes",
"varfont/duplexed_axis_reflow",
"varfont/duplicate_instance_names",
"varfont/instances_in_order",
"varfont/unsupported_axes",
"vtt_volt_data", # very similar to vttclean, may be a good idea to merge them.
Expand Down
1 change: 1 addition & 0 deletions docs/source/fontbakery/checks/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
universal.rst
adobefonts.rst
fontbureau.rst
fontval.rst
Expand Down
36 changes: 0 additions & 36 deletions tests/test_checks_googlefonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3162,42 +3162,6 @@ def test_check_varfont_instance_names(check, vf_ttFont):
assert_SKIP(check(vf_ttFont3))


@check_id("googlefonts/varfont/duplicate_instance_names")
def test_check_varfont_duplicate_instance_names(check, vf_ttFont):
assert_PASS(
check(vf_ttFont), "with a variable font which has unique instance names."
)

from copy import copy

vf_ttFont2 = copy(vf_ttFont)
duplicate_instance_name = (
vf_ttFont2["name"]
.getName(
vf_ttFont2["fvar"].instances[0].subfamilyNameID,
PlatformID.WINDOWS,
WindowsEncodingID.UNICODE_BMP,
WindowsLanguageID.ENGLISH_USA,
)
.toUnicode()
)
vf_ttFont2["name"].setName(
string=duplicate_instance_name,
nameID=vf_ttFont2["fvar"].instances[1].subfamilyNameID,
platformID=PlatformID.WINDOWS,
platEncID=WindowsEncodingID.UNICODE_BMP,
langID=WindowsLanguageID.ENGLISH_USA,
)
assert_results_contain(check(vf_ttFont2), FAIL, "duplicate-instance-names")

# Change the nameID of the 3rd named instance to 456,
# and don't create a name record with that nameID.
name_id = 456
vf_ttFont2["fvar"].instances[2].subfamilyNameID = name_id
msg = assert_results_contain(check(vf_ttFont2), FAIL, "name-record-not-found")
assert f" and nameID {name_id} was not found." in msg


@check_id("googlefonts/metadata/axisregistry_bounds")
def test_check_gfaxisregistry_bounds(check):
"""Validate METADATA.pb axes values are within gf_axisregistry bounds."""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_checks_opentype_os2.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def test_check_fsselection(check):
"with fsSelection:{fsSelection_value} style:{style}...",
)
else:
message = assert_results_contain(
assert_results_contain(
check(ttFont),
FAIL,
expected,
Expand Down
57 changes: 57 additions & 0 deletions tests/test_checks_varfont_duplicate_instance_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from copy import copy

import pytest
from conftest import check_id
from fontTools.ttLib import TTFont

from fontbakery.codetesting import (
assert_PASS,
assert_results_contain,
TEST_FILE,
)
from fontbakery.constants import (
PlatformID,
WindowsEncodingID,
WindowsLanguageID,
)
from fontbakery.status import FAIL


@pytest.fixture
def vf_ttFont():
path = TEST_FILE("varfont/Oswald-VF.ttf")
return TTFont(path)


@check_id("varfont/duplicate_instance_names")
def test_check_varfont_duplicate_instance_names(check, vf_ttFont):
assert_PASS(
check(vf_ttFont), "with a variable font which has unique instance names."
)

vf_ttFont2 = copy(vf_ttFont)
duplicate_instance_name = (
vf_ttFont2["name"]
.getName(
vf_ttFont2["fvar"].instances[0].subfamilyNameID,
PlatformID.WINDOWS,
WindowsEncodingID.UNICODE_BMP,
WindowsLanguageID.ENGLISH_USA,
)
.toUnicode()
)
vf_ttFont2["name"].setName(
string=duplicate_instance_name,
nameID=vf_ttFont2["fvar"].instances[1].subfamilyNameID,
platformID=PlatformID.WINDOWS,
platEncID=WindowsEncodingID.UNICODE_BMP,
langID=WindowsLanguageID.ENGLISH_USA,
)
assert_results_contain(check(vf_ttFont2), FAIL, "duplicate-instance-names")

# Change the nameID of the 3rd named instance to 456,
# and don't create a name record with that nameID.
name_id = 456
vf_ttFont2["fvar"].instances[2].subfamilyNameID = name_id
msg = assert_results_contain(check(vf_ttFont2), FAIL, "name-record-not-found")
assert f" and nameID {name_id} was not found." in msg

0 comments on commit 2aad872

Please sign in to comment.