Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@condition
def descfile(family_directory):
"""Get the path of the DESCRIPTION file of a given font project."""
if family_directory:
descfilepath = os.path.join(family_directory, "DESCRIPTION.en_us.html")
if os.path.exists(descfilepath):
return descfilepath
@condition
def api_gfonts_ttFont(style, remote_styles):
"""Get a TTFont object of a font downloaded from Google Fonts
corresponding to the given TTFont object of
a local font being checked.
"""
if remote_styles and style in remote_styles:
return remote_styles[style]
@condition
def stylenames_are_canonical(fonts):
""" Are all font files named canonically ? """
for font in fonts:
if not canonical_stylename(font):
return False
# otherwise:
return True
@condition
def expected_os2_weight(style):
"""The weight name and the expected OS/2 usWeightClass value inferred from
the style part of the font name
The Google Font's API which serves the fonts can only serve
the following weights values with the corresponding subfamily styles:
250, Thin
275, ExtraLight
300, Light
400, Regular
500, Medium
600, SemiBold
700, Bold
800, ExtraBold
900, Black
@condition
def familyname_with_spaces(familyname):
FAMILY_WITH_SPACES_EXCEPTIONS = {'VT323': 'VT323',
'K2D': 'K2D',
'PressStart2P': 'Press Start 2P',
'ABeeZee': 'ABeeZee',
'IBMPlexMono': 'IBM Plex Mono',
'IBMPlexSans': 'IBM Plex Sans',
'IBMPlexSerif': 'IBM Plex Serif'}
if not familyname:
return None
if familyname in FAMILY_WITH_SPACES_EXCEPTIONS.keys():
return FAMILY_WITH_SPACES_EXCEPTIONS[familyname]
result = []
for c in familyname:
@condition
def familyname_with_spaces(familyname):
FAMILY_WITH_SPACES_EXCEPTIONS = {'VT323': 'VT323',
'K2D': 'K2D',
'PressStart2P': 'Press Start 2P',
'ABeeZee': 'ABeeZee',
'IBMPlexMono': 'IBM Plex Mono',
'IBMPlexSans': 'IBM Plex Sans',
'IBMPlexSerif': 'IBM Plex Serif'}
if not familyname:
return None
if familyname in FAMILY_WITH_SPACES_EXCEPTIONS.keys():
return FAMILY_WITH_SPACES_EXCEPTIONS[familyname]
result = []
for c in familyname:
@condition
def VTT_hinted(ttFont):
# it seems that VTT is the only program that generates a TSI5 table
return 'TSI5' in ttFont
@condition
def is_variable_font(ttFont):
return "fvar" in ttFont.keys()
@condition
def whitelist_librebarcode(font):
font_filenames = [
"LibreBarcode39-Regular.ttf",
"LibreBarcode39Text-Regular.ttf",
"LibreBarcode128-Regular.ttf",
"LibreBarcode128Text-Regular.ttf"
]
for font_filename in font_filenames:
if font_filename in font:
return True
@condition
def font_metadata(family_metadata, font):
if not family_metadata:
return
for f in family_metadata.fonts:
if font.endswith(f.filename):
return f