Merge pull request #2106 from simoncozens/debugging-switch

Turn on feaLib debugging from the environment
This commit is contained in:
Simon Cozens 2020-11-19 06:49:11 -08:00 committed by GitHub
commit 6864100ff4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -2,7 +2,11 @@ from fontTools.misc.py23 import *
from fontTools.misc import sstruct from fontTools.misc import sstruct
from fontTools.misc.textTools import binary2num, safeEval from fontTools.misc.textTools import binary2num, safeEval
from fontTools.feaLib.error import FeatureLibError from fontTools.feaLib.error import FeatureLibError
from fontTools.feaLib.lookupDebugInfo import LookupDebugInfo, LOOKUP_DEBUG_INFO_KEY from fontTools.feaLib.lookupDebugInfo import (
LookupDebugInfo,
LOOKUP_DEBUG_INFO_KEY,
LOOKUP_DEBUG_ENV_VAR,
)
from fontTools.feaLib.parser import Parser from fontTools.feaLib.parser import Parser
from fontTools.feaLib.ast import FeatureFile from fontTools.feaLib.ast import FeatureFile
from fontTools.otlLib import builder as otl from fontTools.otlLib import builder as otl
@ -31,6 +35,7 @@ from collections import defaultdict
import itertools import itertools
import logging import logging
import warnings import warnings
import os
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -210,7 +215,7 @@ class Builder(object):
self.font["BASE"] = base self.font["BASE"] = base
elif "BASE" in self.font: elif "BASE" in self.font:
del self.font["BASE"] del self.font["BASE"]
if debug: if debug or os.environ.get(LOOKUP_DEBUG_ENV_VAR):
self.buildDebg() self.buildDebg()
def get_chained_lookup_(self, location, builder_class): def get_chained_lookup_(self, location, builder_class):

View File

@ -1,6 +1,7 @@
from typing import NamedTuple from typing import NamedTuple
LOOKUP_DEBUG_INFO_KEY = "com.github.fonttools.feaLib" LOOKUP_DEBUG_INFO_KEY = "com.github.fonttools.feaLib"
LOOKUP_DEBUG_ENV_VAR = "FONTTOOLS_LOOKUP_DEBUGGING"
class LookupDebugInfo(NamedTuple): class LookupDebugInfo(NamedTuple):
"""Information about where a lookup came from, to be embedded in a font""" """Information about where a lookup came from, to be embedded in a font"""