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 fontTools.otlLib import builder as otl
from contextlib import contextmanager from contextlib import contextmanager
from fontTools.ttLib import newTable 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 from operator import setitem
import os
import logging import logging
@ -1038,6 +1039,7 @@ def parseGSUBGPOS(lines, font, tableTag):
self.LookupList.LookupCount = len(self.LookupList.Lookup) self.LookupList.LookupCount = len(self.LookupList.Lookup)
if lookupMap is not None: if lookupMap is not None:
lookupMap.applyDeferredMappings() lookupMap.applyDeferredMappings()
if os.environ.get(LOOKUP_DEBUG_ENV_VAR):
if "Debg" not in font: if "Debg" not in font:
font["Debg"] = newTable("Debg") font["Debg"] = newTable("Debg")
font["Debg"].data = {} font["Debg"].data = {}

View File

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