From 6ae1a9a2b69fd0e634ebafbabcd554f47e8bf7ea Mon Sep 17 00:00:00 2001 From: "Alex Xu (Hello71)" Date: Tue, 5 Oct 2021 15:34:26 -0400 Subject: refactoring, clarify logging --- wfs.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/wfs.py b/wfs.py index e67efbe..87d85d8 100755 --- a/wfs.py +++ b/wfs.py @@ -7,7 +7,7 @@ import os import pathlib import sys -from fontTools.subset import Options, Subsetter, load_font +import fontTools.subset from selenium import webdriver logging.basicConfig(format='%(levelname)s: %(message)s') @@ -37,8 +37,8 @@ def start_driver(driver_name): def subset(fontfile, text, fts_opts): logger.info('subsetting %s', fontfile) - font = load_font(fontfile, fts_opts, dontLoadGlyphNames=True) - subsetter = Subsetter(options=fts_opts) + font = fontTools.subset.load_font(fontfile, fts_opts, dontLoadGlyphNames=True) + subsetter = fontTools.subset.Subsetter(options=fts_opts) subsetter.populate(text=text) subsetter.subset(font) font.flavor = 'woff2' @@ -55,8 +55,9 @@ def main(argv): parser.add_argument('--font', help='add font (fontfile:family:weight:style)', action='append') parser.add_argument('file', help='html files', nargs='+') args, leftover = parser.parse_known_intermixed_args(argv) - options = Options() + options = fontTools.subset.Options() files = args.file + options.parse_opts(leftover) + if any(file[0] == '-' for file in files): parser.print_usage() raise Exception('bad arguments') @@ -80,7 +81,7 @@ def main(argv): logger.info('fetching %s', path) driver.get(make_uri(path)) if not args.no_screenshots: - logger.info('replacing fonts for %s', path) + logger.info('preparing %s for screenshot', path) height = driver.execute_script(""" let style = document.createElement('style'); style.innerHTML = arguments[0]; -- cgit v1.2.3-70-g09d2