diff --git a/Lib/gftools/builder/fontc.py b/Lib/gftools/builder/fontc.py index 0db9c340..b9644227 100644 --- a/Lib/gftools/builder/fontc.py +++ b/Lib/gftools/builder/fontc.py @@ -1,7 +1,10 @@ """functionality for running fontc via gftools -This mostly exists so that we can keep as much of the fontc logic in one place, -and not need to dirty up anything else. +gftools has a few special flags that allow it to use fontc, an alternative +font compiler (https://github.com/googlefonts/fontc). + +This module exists to keep the logic related to fontc in one place, and not +dirty up everything else. """ from argparse import Namespace @@ -12,14 +15,13 @@ class FontcArgs: - simple_output_path: Union[Path, None] - fontc_bin_path: Union[Path, None] - single_source: Union[str, None] - # init with 'None' returns a default obj where everything is None def __init__(self, args: Union[Namespace, None]) -> None: if not args: - return None + self.simple_output_path = None + self.fontc_bin_path = None + self.single_source = None + return self.simple_output_path = abspath(args.experimental_simple_output) self.fontc_bin_path = abspath(args.experimental_fontc) self.single_source = args.experimental_single_source diff --git a/Lib/gftools/builder/operations/fontc/__init__.py b/Lib/gftools/builder/operations/fontc/__init__.py index 983d41bc..a0f06b6e 100644 --- a/Lib/gftools/builder/operations/fontc/__init__.py +++ b/Lib/gftools/builder/operations/fontc/__init__.py @@ -2,21 +2,22 @@ from typing import List from gftools.builder.operations import OperationBase -FONTC_PATH = "FONTC_PATH_NOT_SET" +_FONTC_PATH = None # should only be called once, from main, before doing anything else. This is a # relatively non-invasive way to smuggle this value into FontcOperationBase def set_global_fontc_path(path: Path): - global FONTC_PATH - FONTC_PATH = path + global _FONTC_PATH + assert _FONTC_PATH is None, "set_global_fontc_path should only be called once" + _FONTC_PATH = path class FontcOperationBase(OperationBase): @property def variables(self): vars = super().variables - vars["fontc_path"] = FONTC_PATH + vars["fontc_path"] = _FONTC_PATH args = vars.get("args") if args: vars["args"] = rewrite_fontmake_args_for_fontc(args)