Skip to content

Commit

Permalink
Merge pull request #382 from googlefonts/actual-features-fea-name
Browse files Browse the repository at this point in the history
Use the actual path to a UFO's features.fea for a proper error message
  • Loading branch information
madig authored May 29, 2020
2 parents 9d47239 + 091ff36 commit ea96d51
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions Lib/ufo2ft/featureCompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit ea96d51

Please sign in to comment.