From 091ff36a1d4eddf73b9073da50ae0b8da1a5a357 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler Date: Fri, 29 May 2020 09:29:32 +0100 Subject: [PATCH] parseLayoutFeatures: Explicitly set include dir --- Lib/ufo2ft/featureCompiler.py | 16 ++++++++++------ requirements.txt | 2 +- setup.py | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Lib/ufo2ft/featureCompiler.py b/Lib/ufo2ft/featureCompiler.py index 85d89fadf..34abaa0e2 100644 --- a/Lib/ufo2ft/featureCompiler.py +++ b/Lib/ufo2ft/featureCompiler.py @@ -31,16 +31,20 @@ def parseLayoutFeatures(font): if not featxt: return ast.FeatureFile() buf = UnicodeIO(featxt) - # the path is used by the lexer to resolve 'include' statements - # and print filename in error messages. For the UFO spec, this - # should be the path of the UFO, not the inner features.fea: - # https://github.com/unified-font-object/ufo-spec/issues/55 ufoPath = font.path + includeDir = None if ufoPath is not None: - buf.name = ufoPath + # The UFO v3 specification says "Any include() statements must be relative to + # the UFO path, not to the features.fea file itself". We set the `name` + # attribute on the buffer to the actual feature file path, which feaLib will + # pick up and use to attribute errors to the correct file, and explicitly set + # the include directory to the parent of the UFO. + ufoPath = os.path.normpath(ufoPath) + buf.name = os.path.join(ufoPath, "features.fea") + includeDir = os.path.dirname(ufoPath) glyphNames = set(font.keys()) try: - parser = Parser(buf, glyphNames) + parser = Parser(buf, glyphNames, includeDir=includeDir) doc = parser.parse() except IncludedFeaNotFound as e: if ufoPath and os.path.exists(os.path.join(ufoPath, e.args[0])): diff --git a/requirements.txt b/requirements.txt index 44c757908..6d5f12129 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -fonttools[lxml,ufo]==4.10.2 +fonttools[lxml,ufo]==4.11.0 defcon==0.6.0 cu2qu==1.6.7 compreffor==0.5.0 diff --git a/setup.py b/setup.py index 7f7a65208..fd6e65100 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ setup_requires=pytest_runner + wheel + ["setuptools_scm"], tests_require=["pytest>=2.8"], install_requires=[ - "fonttools[ufo]>=4.4.0", + "fonttools[ufo]>=4.11.0", "cu2qu>=1.6.6", "compreffor>=0.4.6", "booleanOperations>=0.9.0",