def com_google_fonts_check_name_typographicfamilyname(ttFont, style, familyname_with_spaces):
  """ Check name table: TYPOGRAPHIC_FAMILY_NAME entries. """
  from fontbakery.utils import name_entry_id

  failed = False
  if style in ['Regular',
               'Italic',
               'Bold',
               'BoldItalic']:
    for name in ttFont['name'].names:
      if name.nameID == NameID.TYPOGRAPHIC_FAMILY_NAME:
        failed = True
        yield FAIL, Message("ribbi",
                            ("Font style is '{}' and, for that reason,"
                             " it is not expected to have a "
                             "{} entry!").format(style,
                                                 name_entry_id(name)))
  else:
    expected_value = familyname_with_spaces
    has_entry = False
    for name in ttFont['name'].names:
      if name.nameID == NameID.TYPOGRAPHIC_FAMILY_NAME:
        string = name.string.decode(name.getEncoding()).strip()
        if string == expected_value:
          has_entry = True
        else:
          failed = True
          yield FAIL, Message("non-ribbi-bad-value",
                              ("Entry {} on the 'name' table: "
                               "Expected '{}' "
                               "but got '{}'.").format(name_entry_id(name),
                                                       expected_value,
                                                       string))
    if not failed and not has_entry:
      failed = True
      yield FAIL, Message("non-ribbi-lacks-entry",
                          ("non-RIBBI fonts must have a"
                           " TYPOGRAPHIC_FAMILY_NAME entry"
                           " on the name table."))
  if not failed:
    yield PASS, "TYPOGRAPHIC_FAMILY_NAME entries are all good."
def com_google_fonts_check_name_typographicfamilyname ( ttFont , style , familyname_with_spaces ) : from fontbakery . utils import name_entry_id failed = False if style in [ 'Regular' , 'Italic' , 'Bold' , 'BoldItalic' ] : for name in ttFont [ 'name' ] . names : if name . nameID == NameID . TYPOGRAPHIC_FAMILY_NAME : failed = True yield FAIL , Message ( "ribbi" , ( "Font style is '{}' and, for that reason," " it is not expected to have a " "{} entry!" ) . format ( style , name_entry_id ( name ) ) ) else : expected_value = familyname_with_spaces has_entry = False for name in ttFont [ 'name' ] . names : if name . nameID == NameID . TYPOGRAPHIC_FAMILY_NAME : string = name . string . decode ( name . getEncoding ( ) ) . strip ( ) if string == expected_value : has_entry = True else : failed = True yield FAIL , Message ( "non-ribbi-bad-value" , ( "Entry {} on the 'name' table: " "Expected '{}' " "but got '{}'." ) . format ( name_entry_id ( name ) , expected_value , string ) ) if not failed and not has_entry : failed = True yield FAIL , Message ( "non-ribbi-lacks-entry" , ( "non-RIBBI fonts must have a" " TYPOGRAPHIC_FAMILY_NAME entry" " on the name table." ) ) if not failed : yield PASS , "TYPOGRAPHIC_FAMILY_NAME entries are all good."
Check name table: TYPOGRAPHIC_FAMILY_NAME entries.