Initial implementation of /check/stylisticset_description
Ensure Stylistic Sets have description.
Stylistic sets must provide description text.
Programs such as InDesign, TextEdit and Inkscape use that
info to display to the users so that they know what a given
stylistic set offers.
(issue
@@ -158,7 +158,8 @@ FONT_FILE_CHECKS = [
'com.google.fonts/check/STAT/gf-axisregistry',
'com.google.fonts/check/STAT/axis_order',
'com.google.fonts/check/mandatory_avar_table',
- 'com.google.fonts/check/missing_small_caps_glyphs'
+ 'com.google.fonts/check/missing_small_caps_glyphs',
+ 'com.google.fonts/check/stylisticset_description'
]
GOOGLEFONTS_PROFILE_CHECKS = \
@@ -5196,6 +5197,42 @@ def com_google_fonts_check_missing_small_caps_glyphs(ttFont):
yield PASS, "OK"
+@check(
+ id = 'com.google.fonts/check/stylisticset_description',
+ rationale = """
+ Stylistic sets must provide description text. Programs such as InDesign, TextEdit and Inkscape use that info to display to the users so that they know what a given stylistic set offers.
+ """,
+ misc_metadata = {
+ 'request': 'https://github.com/googlefonts/fontbakery/issues/3155'
+ }
+)
+def com_google_fonts_check_stylisticset_description(ttFont):
+ """Ensure Stylistic Sets have description."""
+
+ passed = True
+ if 'GSUB' in ttFont and ttFont['GSUB'].table.FeatureList is not None:
+ for record in range(ttFont['GSUB'].table.FeatureList.FeatureCount):
+ feature = ttFont['GSUB'].table.FeatureList.FeatureRecord[record]
+ tag = feature.FeatureTag
+ SSETS = [f'ss{n+1:02d}' for n in range(20)]
+ assert('ss00' not in SSETS)
+ assert('ss01' in SSETS)
+ assert('ss20' in SSETS)
+ assert('ss21' not in SSETS)
+ if tag in SSETS:
+ if feature.Feature.FeatureParams == None:
+ passed = False
+ yield FAIL,\
+ Message('missing-description',
+ f"The stylistic set {tag} lacks a description string on the 'name' table.")
+ else:
+ pass # TODO: maybe here we can add code to make sure that the referenced nameid does exist in the name table.
+ break
+
+ if passed:
+ yield PASS, "OK"
+
+
###############################################################################
def is_librebarcode(font):
