Beispiel #1
0
def main():
  args = parser.parse_args()
  if args.autofix:
    fixed_fonts = []
    for font in args.font:
      filename = os.path.basename(font)

      if not is_filename_canonical(filename):
        print(f"Font filename '{filename}' is not canonical!\n\n"
              f"Filename must be structured as familyname-style.ttf and "
              f"the style must be any of the following {STYLE_NAMES}")
        exit(-1)

      fixer = FontFixer(font)
      fixer.fixes = [fix_fs_selection]
      fixer.fix()
      if fixer.saveit:
        fixed_fonts.append(font)

    if len(fixed_fonts) > 0:
      printInfo([f + '.fix' for f in fixed_fonts], print_csv=args.csv)

    sys.exit(0)

  printInfo(args.font, print_csv=args.csv)
Beispiel #2
0
def main():
  parser = ArgumentParser(description=description)
  parser.add_argument('fonts', nargs='+')
  parser.add_argument('--format-4-subtables', '-f4', default=False,
                      action='store_true',
                      help="Convert cmap subtables to format 4")
  parser.add_argument('--drop-mac-subtable', '-dm', default=False,
                      action='store_true',
                      help='Drop Mac cmap subtables')
  parser.add_argument('--keep-only-pid-0', '-k0', default=False,
                      action='store_true',
                      help=('Keep only cmap subtables with pid=0'
                            ' and drop the rest.'))
  args = parser.parse_args()

  for path in args.fonts:
    fixer = FontFixer(path, verbose=True)
    if args.format_4_subtables:
      print('\nConverting Cmap subtables to format 4...')
      fixer.fixes.append(convert_cmap_subtables_to_v4_with_report)

    if args.keep_only_pid_0:
      print('\nDropping all Cmap subtables,'
            ' except the ones with PlatformId = 0...')
      fixer.fixes.append(drop_nonpid0_cmap)
    elif args.drop_mac_subtable:
      print('\nDropping any Cmap Mac subtable...')
      fixer.fixes.append(drop_mac_cmap)

    fixer.fix()
def main():
    args = parser.parse_args()
    nameids = ['1', '2', '4', '6', '16', '17', '18']
    user_nameids = [x.strip() for x in args.id.split(',')]

    if 'all' not in user_nameids:
        nameids = set(nameids) & set(user_nameids)

    rows = []
    for font in args.font:
        ttfont = ttLib.TTFont(font)
        row = [os.path.basename(font)]
        for name in ttfont['name'].names:
            if str(name.nameID) not in nameids or\
               name.platformID != args.platform:
                continue

            value = name.string.decode(name.getEncoding()) or ''
            row.append(value)

        rows.append(row)

    header = ['filename'] + ['id' + x for x in nameids]

    def as_csv(rows):
        import csv
        import sys
        writer = csv.writer(sys.stdout)
        writer.writerows([header])
        writer.writerows(rows)
        sys.exit(0)

    if args.csv:
        as_csv(rows)

    print(tabulate.tabulate(rows, header, tablefmt="pipe"))

    for path in args.font:
        fixer = FontFixer(path, verbose=True)
        if args.autofix:
            fixer.fixes.append(delete_non_platform1_names)
        if args.drop_superfluous_mac_names:
            if has_mac_names(ttLib.TTFont(path)):
                fixer.fixes.append(drop_superfluous_mac_names)
            else:
                print('font %s has no mac nametable' % path)

        if args.drop_mac_names:
            if has_mac_names(ttLib.TTFont(path)):
                fixer.fixes.append(drop_mac_names)
            else:
                print('font %s has no mac nametable' % path)

        fixer.fix()
Beispiel #4
0
def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--fonts", nargs="+", required=True)
    args = parser.parse_args()

    for font in args.fonts:
        FontFixer(font, fixes=[fix_isFixedPitch], verbose=True).fix()
Beispiel #5
0
def main():
    args = parser.parse_args()
    for path in args.ttf_font:
        if not os.path.exists(path):
            continue

        if args.autofix:
            FontFixer(path, fixes=[fix_pua], verbose=True).fix()
        else:
            font = ttLib.TTFont(path, 0)
            print(("\nThese are the unencoded glyphs in font file '{0}':\n"
                   "{1}").format(path, '\n'.join(get_unencoded_glyphs(font))))
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("font")
    args = parser.parse_args()

    FontFixer(args.font, fixes=[fix_hinted_font], verbose=True).fix()
def main():
  args = parser.parse_args()
  for font_path in args.fonts:
    FontFixer(font_path, fixes=[fix_fs_type], verbose=True).fix()
def main(font_path):
    FontFixer(font_path, verbose=True, fixes=[fix_weight_class]).fix()