mtiLib: check for FONTTOOLS_LOOKUP_DEBUGGING env var

We do the same for feaLib.builder to decide whether to build a Debg table or not: i.e. we check if FONTTOOLS_LOOKUP_DEBUGGING environment variable is defined and if so we go on to build one, otherwise we don't.

Fixes https://github.com/fonttools/fonttools/pull/3018
This commit is contained in:
Cosimo Lupo 2023-03-07 12:02:45 +00:00
parent ea8b9b85d7
commit 8f3d697faa
No known key found for this signature in database
GPG Key ID: DF65A8A5A119C9A8
2 changed files with 19 additions and 11 deletions

View File

@ -13,8 +13,9 @@ from fontTools.ttLib.tables.otBase import ValueRecord, valueRecordFormatDict
from fontTools.otlLib import builder as otl
from contextlib import contextmanager
from fontTools.ttLib import newTable
from fontTools.feaLib.lookupDebugInfo import LOOKUP_DEBUG_INFO_KEY
from fontTools.feaLib.lookupDebugInfo import LOOKUP_DEBUG_ENV_VAR, LOOKUP_DEBUG_INFO_KEY
from operator import setitem
import os
import logging
@ -1038,16 +1039,17 @@ def parseGSUBGPOS(lines, font, tableTag):
self.LookupList.LookupCount = len(self.LookupList.Lookup)
if lookupMap is not None:
lookupMap.applyDeferredMappings()
if "Debg" not in font:
font["Debg"] = newTable("Debg")
font["Debg"].data = {}
debug = (
font["Debg"]
.data.setdefault(LOOKUP_DEBUG_INFO_KEY, {})
.setdefault(tableTag, {})
)
for name, lookup in lookupMap.items():
debug[str(lookup)] = ["", name, ""]
if os.environ.get(LOOKUP_DEBUG_ENV_VAR):
if "Debg" not in font:
font["Debg"] = newTable("Debg")
font["Debg"].data = {}
debug = (
font["Debg"]
.data.setdefault(LOOKUP_DEBUG_INFO_KEY, {})
.setdefault(tableTag, {})
)
for name, lookup in lookupMap.items():
debug[str(lookup)] = ["", name, ""]
featureMap.applyDeferredMappings()
container.table = self

View File

@ -1,5 +1,6 @@
from fontTools.misc.xmlWriter import XMLWriter
from fontTools.ttLib import TTFont
from fontTools.feaLib.lookupDebugInfo import LOOKUP_DEBUG_ENV_VAR
from fontTools import mtiLib
import difflib
from io import StringIO
@ -8,6 +9,11 @@ import sys
import pytest
@pytest.fixture(autouse=True)
def set_lookup_debug_env_var(monkeypatch):
monkeypatch.setenv(LOOKUP_DEBUG_ENV_VAR, "1")
class MtiTest:
GLYPH_ORDER = [