Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def make_profile(check_list, variable_font=False):
profile = profile_factory(default_section=Section("SIL Fonts"))
profile.auto_register(globals())
# Exclude all the checks we don't want to run
for checkid in check_list:
if checkid in profile._check_registry:
check_item = check_list[checkid]
exclude = check_item["exclude"] if "exclude" in check_item else False
if exclude: profile.remove_check(checkid)
# Exclude further sets of checks to reduce number of skips and so have less clutter in html results
# (Currently just working with variable font tests, but structured to cover more types of checks later)
for checkid in sorted(set(profile._check_registry.keys())):
section = profile._check_registry[checkid]
check = section.get_check(checkid)
conditions = getattr(check, "conditions")
exclude = False
from fontbakery.callable import check
from fontbakery.callable import condition
from fontbakery.checkrunner import Section, PASS, FAIL, WARN
from fontbakery.fonts_profile import profile_factory
from tests.test_general import (
font_family,
font_style,
is_italic,
com_roboto_fonts_check_italic_angle,
com_roboto_fonts_check_fs_type,
com_roboto_fonts_check_vendorid,
com_roboto_fonts_check_digit_widths,
)
profile = profile_factory(default_section=Section("Roboto web v3"))
ROBOTO_PROFILE_CHECKS = [
"com.roboto.fonts/check/vertical_metrics",
"com.roboto.fonts/check/oblique_bits_not_set",
"com.roboto.fonts/check/unique_id",
"com.roboto.fonts/check/hinting",
"com.roboto.fonts/check/italic_angle",
"com.roboto.fonts/check/fs_type",
"com.roboto.fonts/check/vendorid",
"com.roboto.fonts/check/digit_widths",
]
@check(
id="com.roboto.fonts/check/vertical_metrics",
)
ROBOTO_GENERAL_CHECKS += [
"com.roboto.fonts/check/italic_angle",
"com.roboto.fonts/check/fs_type",
"com.roboto.fonts/check/vendorid",
"com.roboto.fonts/check/charset_coverage",
"com.roboto.fonts/check/digit_widths",
"com.roboto.fonts/check/numr_mapped_to_supr",
"com.roboto.fonts/check/name_copyright",
"com.roboto.fonts/check/name_unique_id",
"com.roboto.fonts/check/vertical_metrics",
"com.roboto.fonts/check/cmap4",
]
profile_imports = ('fontbakery.profiles.universal',)
profile = profile_factory(default_section=Section("Roboto v3 general"))
# Checks ported from https://github.com/googlefonts/roboto/blob/master/scripts/run_general_tests.py
@condition
def is_italic(ttFont):
return True if "Italic" in ttFont.reader.file.name else False
@condition
def is_vf(ttFont):
return True if "fvar" in ttFont else False
def font_style(ttFont):
subfamily_name = ttFont['name'].getName(2, 3, 1, 1033)
def all_checks_dict(): # An ordered dict of all checks designed for exporting the data
profile = profile_factory(default_section=Section("SIL Fonts"))
profile.auto_register(globals())
check_dict=OrderedDict()
for checkid in sorted(set(profile._check_registry.keys())):
section = profile._check_registry[checkid]
check = section.get_check(checkid)
conditions = getattr(check, "conditions")
conditionstxt=""
for condition in conditions:
conditionstxt += condition + "\n"
conditionstxt = conditionstxt.strip()
rationale = getattr(check,"rationale")
rationale = "" if rationale is None else rationale.strip().replace("\n ", "\n") # Remove extraneous whitespace
import os
from fontbakery.checkrunner import Section, PASS, FAIL, WARN, ERROR, INFO, SKIP
from fontbakery.callable import condition, check, disable
from fontbakery.constants import PriorityLevel
from fontbakery.message import Message
from fontbakery.fonts_profile import profile_factory
from fontbakery.profiles.opentype import OPENTYPE_PROFILE_CHECKS
profile_imports = ('fontbakery.profiles.opentype',)
profile = profile_factory(default_section=Section("Universal"))
THIRDPARTY_CHECKS = [
'com.google.fonts/check/ots',
'com.google.fonts/check/ftxvalidator',
'com.google.fonts/check/ftxvalidator_is_available'
]
UNIVERSAL_PROFILE_CHECKS = \
OPENTYPE_PROFILE_CHECKS + \
THIRDPARTY_CHECKS + [
'com.google.fonts/check/name/trailing_spaces',
'com.google.fonts/check/family/win_ascent_and_descent',
'com.google.fonts/check/os2_metrics_match_hhea',
'com.google.fonts/check/fontbakery_version',
'com.google.fonts/check/ttx-roundtrip',
'com.google.fonts/check/family/single_directory',
import os
from fontbakery.callable import check
from fontbakery.checkrunner import ERROR, FAIL, INFO, PASS, WARN, Section
# used to inform get_module_profile whether and how to create a profile
from fontbakery.fonts_profile import profile_factory # NOQA pylint: disable=unused-import
from .shared_conditions import is_variable_font
profile_imports = ['.shared_conditions']
profile = profile_factory(default_section=Section("Checks inherited from Microsoft Font Validator"))
@check(
id = 'com.google.fonts/check/fontvalidator'
)
def com_google_fonts_check_fontvalidator(font):
"""Checking with Microsoft Font Validator."""
# In some cases we want to override the severity level of
# certain checks in FontValidator:
downgrade_to_warn = [
# There are reports that this fontval check has an out-of-date
# understanding of valid bits in fsSelection.
# More info at:
# https://github.com/googlei18n/fontmake/issues/414#issuecomment-379408127
"There are undefined bits set in fsSelection field",
"""
Checks for Adobe Fonts (formerly known as Typekit).
"""
import unicodedata
from fontbakery.callable import check
from fontbakery.checkrunner import Section, PASS, FAIL, WARN
from fontbakery.fonts_profile import profile_factory
from fontbakery.profiles.universal import UNIVERSAL_PROFILE_CHECKS
profile_imports = ('fontbakery.profiles.universal',)
profile = profile_factory(default_section=Section("Adobe Fonts"))
ADOBEFONTS_PROFILE_CHECKS = \
UNIVERSAL_PROFILE_CHECKS + [
'com.adobe.fonts/check/family/consistent_upm',
'com.adobe.fonts/check/find_empty_letters'
]
OVERRIDDEN_CHECKS = [
'com.google.fonts/check/dsig',
'com.google.fonts/check/whitespace_glyphs',
'com.google.fonts/check/valid_glyphnames',
]
ADOBEFONTS_PROFILE_CHECKS += [f'{cid}:{profile.profile_tag}' for cid in OVERRIDDEN_CHECKS]
ADOBEFONTS_PROFILE_CHECKS[:] = [cid for cid in ADOBEFONTS_PROFILE_CHECKS
if cid not in OVERRIDDEN_CHECKS]
"os2",
"post",
"name",
"loca",
"hhea",
"dsig",
"hmtx",
"gpos",
"kern",
"glyf",
"fvar",
"shared_conditions",
),
)
profile_imports = (OPENTYPE_PROFILE_IMPORTS, )
profile = profile_factory(default_section=Section("OpenType Specification Checks"))
OPENTYPE_PROFILE_CHECKS = [
'com.google.fonts/check/family/underline_thickness',
'com.google.fonts/check/family/panose_proportion',
'com.google.fonts/check/family/panose_familytype',
'com.google.fonts/check/family/equal_unicode_encodings',
'com.google.fonts/check/family/equal_font_versions',
'com.adobe.fonts/check/family/bold_italic_unique_for_nameid1',
'com.adobe.fonts/check/family/max_4_fonts_per_family_name',
'com.adobe.fonts/check/name/postscript_vs_cff',
'com.adobe.fonts/check/name/postscript_name_consistency',
'com.adobe.fonts/check/name/empty_records',
'com.google.fonts/check/name/no_copyright_on_description',
'com.google.fonts/check/name/line_breaks',
'com.google.fonts/check/name/rfn',
'com.google.fonts/check/name/match_familyname_fullfont',