How to use fontbakery - 10 common examples

To help you get started, we’ve selected a few fontbakery examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TypeNetwork / Roboto / tests / test_general.py View on Github external
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"
github silnrsi / pysilfont / lib / silfont / fbtests / ttfchecks.py View on Github external
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."
github silnrsi / pysilfont / lib / silfont / fbtests / ttfchecks.py View on Github external
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.'
github silnrsi / pysilfont / lib / silfont / fbtests / ttfchecks.py View on Github external
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
github TypeNetwork / Roboto / tests / test_general.py View on Github external
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"
github silnrsi / pysilfont / lib / silfont / fbtests / ttfchecks.py View on Github external
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."
github googlefonts / fontbakery / tests / test_parse.py View on Github external
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"
github googlefonts / fontbakery / tests / test_parse.py View on Github external
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"
github googlefonts / fontbakery / tests / test_parse.py View on Github external
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"
github googlefonts / fontbakery / tests / test_parse.py View on Github external
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"