How to use the fontbakery.checkrunner.PASS function in fontbakery

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 googlefonts / fontbakery / Lib / fontbakery / commands / check_profile.py View on Github external
theme = NO_COLORS_THEME
  else:
    if args.light_theme:
      theme = LIGHT_THEME
    elif args.dark_theme:
      theme = DARK_THEME
    elif sys.platform == "darwin":
      # The vast majority of MacOS users seem to use a light-background on the text terminal
      theme = LIGHT_THEME
    else:
      # For orther systems like GNU+Linux and Windows, a dark terminal seems to be more common.
      theme = DARK_THEME


  if args.list_checks:
    if args.loglevels == [PASS]: # if verbose:
      for section in profile._sections.values():
        print(theme["list-checks: section"]("\nSection:") + " " + section.name)
        for check in section._checks:
          print(theme["list-checks: check-id"](check.id) + "\n" +
                theme["list-checks: description"](f'"{check.description}"') + "\n")
    else:
      for section_name, section in profile._sections.items():
        for check in section._checks:
          print(check.id)
    sys.exit()

  values_ = {}
  if values is not None:
    values_.update(values)

  # values_keys are returned by profile.setup_argparse
github googlefonts / fontbakery / Lib / fontbakery / profiles / hhea.py View on Github external
" across all glyphs, but {}% of them"
                  " have a different value: {}"
                  "".format(round(100 * outliers_percentage, 2),
                            pretty_print_list(outliers)))
    if zero_or_double_width_outliers:
      yield WARN,\
            Message("variable-monospaced",
                    "Double-width and/or zero-width glyphs"
                    " were detected. These glyphs should be set"
                    " to the same width as all others"
                    " and then add GPOS single pos lookups"
                    " that zeros/doubles the widths as needed:"
                    " {}".format(pretty_print_list(
                                 zero_or_double_width_outliers)))
  else:
    yield PASS, ("hhea.advanceWidthMax is equal"
                 " to all glyphs' advanceWidth in this monospaced font.")
github googlefonts / fontbakery / Lib / fontbakery / profiles / name.py View on Github external
def com_adobe_fonts_check_name_empty_records(ttFont):
    """Check name table for empty records."""
    failed = False
    for name_record in ttFont['name'].names:
        name_string = name_record.toUnicode().strip()
        if len(name_string) == 0:
            failed = True
            name_key = tuple([name_record.platformID, name_record.platEncID,
                             name_record.langID, name_record.nameID])
            yield FAIL,\
                  Message("empty-record",
                          f'"name" table record with key={name_key} is'
                          f' empty and should be removed.')
    if not failed:
        yield PASS, ("No empty name table records found.")
github googlefonts / fontbakery / Lib / fontbakery / profiles / fvar.py View on Github external
def com_google_fonts_check_varfont_bold_wght_coord(ttFont, bold_wght_coord):
  """The variable font 'wght' (Weight) axis coordinate must be 700 on the
  'Bold' instance."""

  if bold_wght_coord == 700:
    yield PASS, "Bold:wght is 700."
  else:
    yield FAIL,\
          Message("not-700",
                  f'The "wght" axis coordinate of'
                  f' the "Bold" instance must be 700.'
github googlefonts / fontbakery / Lib / fontbakery / profiles / cmap.py View on Github external
if table.format == 4:
        cmap = table
        break
    # Could a font lack a format 4 cmap table ?
    # If we ever find one of those, it would crash the check here.
    # Then we'd have to yield a FAIL regarding the missing table entry.
    if not encoding:
      encoding = cmap.platEncID
    if encoding != cmap.platEncID:
      failed = True
  if failed:
    yield FAIL,\
          Message("mismatch",
                  "Fonts have different unicode encodings.")
  else:
    yield PASS, "Fonts have equal unicode encodings."
github googlefonts / fontbakery / Lib / fontbakery / profiles / glyf.py View on Github external
shorten=10,
                                                sep="\n\t* ")
    yield WARN,\
          Message("points-out-of-bounds",
                  f"The following glyphs have coordinates"
                  f" which are out of bounds:\n"
                  f"{formatted_list}\n"
                  f"\n"
                  f"This happens a lot when points are not extremes,"
                  f" which is usually bad. However, fixing this alert"
                  f" by adding points on extremes may do more harm"
                  f" than good, especially with italics,"
                  f" calligraphic-script, handwriting, rounded and"
                  f" other fonts. So it is common to ignore this message.")
  else:
    yield PASS, "All glyph paths have coordinates within bounds!"
github googlefonts / fontbakery / Lib / fontbakery / profiles / gpos.py View on Github external
def com_google_fonts_check_gpos_kerning_info(ttFont):
  """Does GPOS table have kerning information?"""
  if not has_kerning_info(ttFont):
    yield WARN,\
          Message("lacks-kern-info",
                  "GPOS table lacks kerning information.")
  else:
    yield PASS, "GPOS table has got kerning information."
github googlefonts / fontbakery / Lib / fontbakery / commands / check_profile.py View on Github external
argument_parser.add_argument(
      "-x",
      "--exclude-checkid",
      action="append",
      help=(
          "Exclude check-ids (or parts of their name) from execution. "
          "Use this option multiple times to exclude multiple checks."
      ),
  )

  def log_levels_get(key):
    if key in log_levels:
      return log_levels[key]
    raise argparse.ArgumentTypeError('Key "{}" must be one of: {}.'.format(
                                          key, ', '.join(log_levels.keys())))
  argument_parser.add_argument('-v', '--verbose', dest='loglevels', const=PASS, action='append_const',
                      help='Shortcut for `-l PASS`.\n')

  argument_parser.add_argument('-l', '--loglevel', dest='loglevels', type=log_levels_get,
                      action='append',
                      metavar= 'LOGLEVEL',
                      help='Report checks with a result of this status or higher.\n'
                           'One of: {}.\n'
                           '(default: {})'.format(', '.join(log_levels.keys())
                                                   , DEFAULT_LOG_LEVEL.name))

  argument_parser.add_argument('-m', '--loglevel-messages', default=None, type=log_levels_get,
                      help=('Report log messages of this status or higher.\n'
                            'Messages are all status lines within a check.\n'
                            'One of: {}.\n'
                            '(default: LOGLEVEL)'
                            ).format(', '.join(log_levels.keys())))