How to use the gftools.util.google_fonts.FsSelectionFlags function in gftools

To help you get started, we’ve selected a few gftools 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 googlefonts / gftools / bin / gftools-sanity-check.py View on Github external
Args:
    path: Path to directory containing font.
    font: A font record from a METADATA.pb.
    ttf: A fontTools.ttLib.TTFont for the font.
  Returns:
    A list of ResultMessageTuple for tests performed.
  """
  results = []

  font_file = font.filename
  full_font_file = os.path.join(path, font_file)
  expected_style = font.style
  expected_weight = font.weight

  os2 = ttf['OS/2']
  fs_selection_flags = fonts.FsSelectionFlags(os2.fsSelection)
  actual_weight = os2.usWeightClass
  fs_type = os2.fsType

  marked_oblique = 'OBLIQUE' in fs_selection_flags
  marked_italic = 'ITALIC' in fs_selection_flags
  marked_bold = 'BOLD' in fs_selection_flags

  expect_italic = _IsItalic(expected_style)
  expect_bold = _IsBold(expected_weight)
  # Per Dave C, we should NEVER set oblique, use 0 for italic
  expect_oblique = False

  results.append(
      ResultMessageTuple(marked_italic == expect_italic,
                         '%s %s/%d fsSelection marked_italic %d' %
                         (font_file, expected_style, expected_weight,