summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2021-10-05 15:34:26 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2021-10-05 15:34:26 -0400
commit6ae1a9a2b69fd0e634ebafbabcd554f47e8bf7ea (patch)
tree93535b5fdce7abdb232f2067c679cd248f2dcb6e
parent746ab5961c023450f7774d568e052cee44946765 (diff)
downloadwfs-6ae1a9a2b69fd0e634ebafbabcd554f47e8bf7ea.tar.xz
wfs-6ae1a9a2b69fd0e634ebafbabcd554f47e8bf7ea.zip
refactoring, clarify logging
-rwxr-xr-xwfs.py11
1 files 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];