How to use the gftools.utils.download_family_from_Google_Fonts 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-check-font-version.py View on Github external
def main():
  parser = ArgumentParser(description=__doc__)
  parser.add_argument('family',
            help='Name of font family')
  parser.add_argument('-wc', '--web-compare',
                      help='Compare against a web url .zip family')
  parser.add_argument('-lc', '--local-compare', nargs='+',
                      help='Compare against a set of local ttfs')
  args = parser.parse_args()

  google_family = download_family_from_Google_Fonts(args.family)
  google_family_fonts = [TTFont(f) for f in google_family]
  google_family_version = parse_version_head(google_family_fonts)


  if args.web_compare:
    if args.web_compare.endswith('.zip'):
      web_family_zip = ZipFile(download_file(args.web_compare))
      web_family = fonts_from_zip(web_family_zip)
      web_family_fonts = [TTFont(f) for f in web_family
                          if f.name.endswith(".ttf")]
      web_family_name = set(f.reader.file.name.split('-')[0] for f in web_family)
      web_family_version = parse_version_head(web_family_fonts)
    print('Google Fonts Version of %s is v%s' % (
      args.family,
      google_family_version
    ))
github googlefonts / gftools / bin / gftools-qa.py View on Github external
mkdir(fonts_dir)
    if args.fonts:
        [shutil.copy(f, fonts_dir) for f in args.fonts]
        fonts = args.fonts
    elif args.pull_request:
        fonts = download_files_in_github_pr(args.pull_request, fonts_dir)
        if not fonts:
            logger.info("No fonts found in pull request. Skipping")
            return
    elif args.github_dir:
        fonts = download_files_in_github_dir(args.github_dir, fonts_dir)
        if not fonts:
            logger.info("No fonts found in github dir. Skipping")
            return
    elif args.googlefonts:
        fonts = download_family_from_Google_Fonts(args.googlefonts, fonts_dir)

    if args.filter_fonts:
        re_filter = re.compile(args.filter_fonts)
        fonts = [f for f in fonts if re_filter.search(f)]

    ttfonts = [TTFont(f) for f in fonts if f.endswith((".ttf", ".otf"))]
    family_name = family_name_from_fonts(ttfonts)
    family_on_gf = Google_Fonts_has_family(family_name)

    # Retrieve fonts_before and store in out dir
    fonts_before = None
    if any([args.fonts_before, args.pull_request_before, args.github_dir_before]) or \
           (args.googlefonts_before and family_on_gf):
        fonts_before_dir = os.path.join(args.out, "fonts_before")
        mkdir(fonts_before_dir, overwrite=False)
    if args.fonts_before:
github googlefonts / gftools / bin / gftools-qa.py View on Github external
(args.googlefonts_before and family_on_gf):
        fonts_before_dir = os.path.join(args.out, "fonts_before")
        mkdir(fonts_before_dir, overwrite=False)
    if args.fonts_before:
        [shutil.copy(f, fonts_before_dir) for f in args.fonts_before]
        fonts_before = args.fonts_before
    elif args.pull_request_before:
        fonts_before = download_files_in_github_pr(
            args.pull_request_before, fonts_before_dir
        )
    elif args.github_dir_before:
        fonts_before = download_files_in_github_dir(
            args.github_dir_before, font_before_dir
        )
    elif args.googlefonts_before and family_on_gf:
        fonts_before = download_family_from_Google_Fonts(
            family_name, fonts_before_dir
        )

    if fonts_before:
        ttfonts_before = [TTFont(f) for f in fonts_before if f.endswith((".ttf", ".otf"))]
        qa = FontQA(ttfonts, ttfonts_before, args.out)
    else:
        qa = FontQA(ttfonts, out=args.out)

    if args.auto_qa and family_on_gf:
        qa.googlefonts_upgrade()
    elif args.auto_qa and not family_on_gf:
        qa.googlefonts_new()
    if args.plot_glyphs:
        qa.plot_glyphs()
    if args.browser_previews: