Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def com_roboto_fonts_check_vendorid(ttFont):
"""Check vendorID is correct"""
if ttFont["OS/2"].achVendID != "GOOG":
yield FAIL, "OS/2.achVendID must be set to 'GOOG'"
else:
yield PASS, "OS/2.achVendID is set corrrectly"
f'The NameID.VERSION_STRING'
f' (nameID={NameID.VERSION_STRING}) value must'
f' follow the pattern "Version X.nnn devstring" with X.nnn'
f' greater than or equal to 0.000.'
f' Current version string is: "{ventry}"')
elif not re.match(r'Version [1-9][0-9]*\.\d{3}$', ventry):
warned = True
yield WARN, \
Message("nonproduction-version-strings",
f'For production fonts, the NameID.VERSION_STRING'
f' (nameID={NameID.VERSION_STRING}) value must'
f' follow the pattern "Version X.nnn" with X.nnn'
f' greater than or equal to 1.000.'
f' Current version string is: "{ventry}"')
if not failed and not warned:
yield PASS, "Version format in NAME table entries is correct."
def org_sil_software_version_format(ttFont):
"Version format is correct in 'name' table?"
from fontbakery.utils import get_name_entry_strings
import re
failed = False
warned = False
version_entries = get_name_entry_strings(ttFont, NameID.VERSION_STRING)
if len(version_entries) == 0:
failed = True
yield FAIL,\
Message("no-version-string",
f"Font lacks a NameID.VERSION_STRING"
f" (nameID={NameID.VERSION_STRING}) entry")
for ventry in version_entries:
if not re.match(r'Version [0-9]+\.\d{3}( .+)*$', ventry):
failed = True
yield FAIL,\
Message("bad-version-strings",
f'The NameID.VERSION_STRING'
f' (nameID={NameID.VERSION_STRING}) value must'
f' follow the pattern "Version X.nnn devstring" with X.nnn'
f' greater than or equal to 0.000.'
def org_sil_software_version_format(ttFont):
"Version format is correct in 'name' table?"
from fontbakery.utils import get_name_entry_strings
import re
failed = False
warned = False
version_entries = get_name_entry_strings(ttFont, NameID.VERSION_STRING)
if len(version_entries) == 0:
failed = True
yield FAIL,\
Message("no-version-string",
f"Font lacks a NameID.VERSION_STRING"
f" (nameID={NameID.VERSION_STRING}) entry")
for ventry in version_entries:
if not re.match(r'Version [0-9]+\.\d{3}( .+)*$', ventry):
failed = True
yield FAIL,\
Message("bad-version-strings",
f'The NameID.VERSION_STRING'
f' (nameID={NameID.VERSION_STRING}) value must'
f' follow the pattern "Version X.nnn devstring" with X.nnn'
f' greater than or equal to 0.000.'
f' Current version string is: "{ventry}"')
elif not re.match(r'Version [1-9][0-9]*\.\d{3}$', ventry):
warned = True
def com_roboto_fonts_check_italic_angle(ttFont):
"""Check italic fonts have correct italic angle"""
failed = False
if ttFont['post'].italicAngle != -12:
yield FAIL, "post.italicAngle must be set to -12"
else:
yield PASS, "post.italicAngle is set correctly"
for ventry in version_entries:
if not re.match(r'Version [0-9]+\.\d{3}( .+)*$', ventry):
failed = True
yield FAIL,\
Message("bad-version-strings",
f'The NameID.VERSION_STRING'
f' (nameID={NameID.VERSION_STRING}) value must'
f' follow the pattern "Version X.nnn devstring" with X.nnn'
f' greater than or equal to 0.000.'
f' Current version string is: "{ventry}"')
elif not re.match(r'Version [1-9][0-9]*\.\d{3}$', ventry):
warned = True
yield WARN, \
Message("nonproduction-version-strings",
f'For production fonts, the NameID.VERSION_STRING'
f' (nameID={NameID.VERSION_STRING}) value must'
f' follow the pattern "Version X.nnn" with X.nnn'
f' greater than or equal to 1.000.'
f' Current version string is: "{ventry}"')
if not failed and not warned:
yield PASS, "Version format in NAME table entries is correct."
style = _style_parse("Italic Bold Condensed")
assert style.name == "Condensed Bold Italic"
style = _style_parse("Extra-Bold")
assert style.name == "ExtraBold"
style = _style_parse("Extra Bold")
assert style.name == "ExtraBold"
style = _style_parse("Extra Bold Italic")
assert style.name == "ExtraBold Italic"
style = _style_parse("Semi Condensed Extra Light")
assert style.name == "SemiCondensed ExtraLight"
style = _style_parse("wt400 It")
assert style.name == "Italic"
style = _style_parse("Regular Italic")
assert style.name == "Italic"
style = _style_parse("ExLt ExCd It")
assert style.name == "ExtraCondensed ExtraLight Italic"
style = _style_parse("Thn It")
assert style.name == "Thin Italic"
style = _style_parse("Bold Oblique")
assert style.name == "Bold Italic"
style = _style_parse("UltCndExtBdIt")
assert style.name =="UltraCondensed ExtraBold Italic"
def test_name():
style = _style_parse("Bold Condensed")
assert style.name == "Condensed Bold"
style = _style_parse("Italic Bold Condensed")
assert style.name == "Condensed Bold Italic"
style = _style_parse("Extra-Bold")
assert style.name == "ExtraBold"
style = _style_parse("Extra Bold")
assert style.name == "ExtraBold"
style = _style_parse("Extra Bold Italic")
assert style.name == "ExtraBold Italic"
style = _style_parse("Semi Condensed Extra Light")
assert style.name == "SemiCondensed ExtraLight"
def test_name():
style = _style_parse("Bold Condensed")
assert style.name == "Condensed Bold"
style = _style_parse("Italic Bold Condensed")
assert style.name == "Condensed Bold Italic"
style = _style_parse("Extra-Bold")
assert style.name == "ExtraBold"
style = _style_parse("Extra Bold")
assert style.name == "ExtraBold"
style = _style_parse("Extra Bold Italic")
assert style.name == "ExtraBold Italic"
style = _style_parse("Semi Condensed Extra Light")
assert style.name == "SemiCondensed ExtraLight"
style = _style_parse("wt400 It")
assert style.name == "Italic"
style = _style_parse("Regular Italic")
assert style.name == "Italic"
style = _style_parse("ExLt ExCd It")
assert style.name == "ExtraCondensed ExtraLight Italic"
style = _style_parse("Thn It")
assert style.name == "Thin Italic"
style = _style_parse("Bold Oblique")
assert style.name == "Bold Italic"
style = _style_parse("UltCndExtBdIt")
assert style.name =="UltraCondensed ExtraBold Italic"
style = _style_parse("Regular Italic 18pt")
assert style.name == "18pt Italic"
style = _style_parse("Condensed Italic 10pt ExtraBold")
assert style.name == "10pt Condensed ExtraBold Italic"