def name_entry_id(name): from fontbakery.constants import (NameID, PlatformID) return "[{}({}):{}({})]".format(NameID(name.nameID).name, name.nameID, PlatformID(name.platformID).name, name.platformID)
def com_google_fonts_check_057(ttFont): """Name table entries should not contain line-breaks.""" failed = False for name in ttFont["name"].names: string = name.string.decode(name.getEncoding()) if "\n" in string: failed = True yield FAIL, ("Name entry {} on platform {} contains" " a line-break.").format(NameID(name.nameID).name, PlatformID(name.platformID).name) if not failed: yield PASS, ("Name table entries are all single-line" " (no line-breaks found).")
def com_google_fonts_check_163(ttFont): """Combined length of family and style must not exceed 20 characters.""" from unidecode import unidecode from fontbakery.utils import (get_name_entries, get_name_entry_strings) failed = False for familyname in get_name_entries(ttFont, NameID.FONT_FAMILY_NAME): # we'll only match family/style name entries with the same platform ID: plat = familyname.platformID familyname_str = familyname.string.decode(familyname.getEncoding()) for stylename_str in get_name_entry_strings(ttFont, NameID.FONT_SUBFAMILY_NAME, platformID=plat): if len(familyname_str + stylename_str) > 20: failed = True yield WARN, ("The combined length of family and style" " exceeds 20 chars in the following '{}' entries:" " FONT_FAMILY_NAME = '{}' / SUBFAMILY_NAME = '{}'" "").format( PlatformID(plat).name, unidecode(familyname_str), unidecode(stylename_str)) if not failed: yield PASS, "All name entries are good."