Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected glyph class definition or statement: got NAME condition #594

Closed
romashamin opened this issue Jul 31, 2022 · 1 comment
Closed

Comments

@romashamin
Copy link

romashamin commented Jul 31, 2022

I’m trying to build font files from .glyphs source (repo link) and having this Expected glyph class definition or statement: got NAME condition error.

Earlier in that Cn Th master (in it only) were Add Feature custom parameter and special threeCahrs/twoChars classes for ligatures.
image

I’ve deleted all of these and now settings for Cn Th master seem to me as identical to other masters. However something’s still wrong.

Glyphs app generates a variable font without problems.

I’m out of ideas on what could cause it. Could someone help me?

% gftools builder sources/config.yaml
INFO:fontmake.font_project:Building master UFOs and designspace from Glyphs source
INFO:fontmake.font_project:Building variable fonts ../fonts/variable/Martian Mono-VF.ttf
Traceback (most recent call last):
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/fontmake/font_project.py", line 1065, in run_from_designspace
    self._run_from_designspace_interpolatable(
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/fontmake/font_project.py", line 1157, in _run_from_designspace_interpolatable
    self.build_variable_fonts(
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/fontmake/font_project.py", line 384, in build_variable_fonts
    fonts = ufo2ft.compileVariableTTFs(
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/ufo2ft/__init__.py", line 596, in compileVariableTTFs
    vfNameToBaseUfo = _compileNeededSources(
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/ufo2ft/__init__.py", line 785, in _compileNeededSources
    ttfDesignSpace = compileInterpolatableFunc(
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/ufo2ft/__init__.py", line 384, in compileInterpolatableTTFsFromDS
    for source, ttf in zip(result.sources, ttfs):
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/ufo2ft/__init__.py", line 318, in compileInterpolatableTTFs
    compileFeatures(ufo, ttf, glyphSet=glyphSet, **kwargs)
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/ufo2ft/__init__.py", line 507, in compileFeatures
    otFont = featureCompiler.compile()
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/ufo2ft/featureCompiler.py", line 127, in compile
    self.setupFeatures()
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/ufo2ft/featureCompiler.py", line 262, in setupFeatures
    featureFile = parseLayoutFeatures(self.ufo)
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/ufo2ft/featureCompiler.py", line 49, in parseLayoutFeatures
    doc = parser.parse()
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/fontTools/feaLib/parser.py", line 105, in parse
    statements.append(self.parse_feature_block_())
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/fontTools/feaLib/parser.py", line 1738, in parse_feature_block_
    self.parse_block_(block, vertical, stylisticset, size_feature, cv_feature)
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/fontTools/feaLib/parser.py", line 1982, in parse_block_
    raise FeatureLibError(
fontTools.feaLib.error.FeatureLibError: /Users/roma/Code/mono/sources/master_ufo/MartianMono-CnTh.ufo/features.fea:154:1: Expected glyph class definition or statement: got NAME condition

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/roma/Code/mono/myenv/bin/gftools-builder.py", line 83, in <module>
    builder.build()
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/gftools/builder/__init__.py", line 192, in build
    self.build_variable()
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/gftools/builder/__init__.py", line 294, in build_variable
    output_files = self.run_fontmake(source, args)
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/gftools/builder/__init__.py", line 334, in run_fontmake
    FontProject().run_from_glyphs(source, **args)
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/fontmake/font_project.py", line 787, in run_from_glyphs
    self.run_from_designspace(designspace_path, **kwargs)
  File "/Users/roma/Code/mono/myenv/lib/python3.9/site-packages/fontmake/font_project.py", line 1080, in run_from_designspace
    raise FontmakeError(
fontmake.errors.FontmakeError: In 'Martian Mono.glyphs' -> 'master_ufo/MartianMono.designspace': Generating fonts from Designspace failed: /Users/roma/Code/mono/sources/master_ufo/MartianMono-CnTh.ufo/features.fea:154:1: Expected glyph class definition or statement: got NAME condition
@simoncozens
Copy link
Contributor

The problem is not the replace feature; it's the variable feature code in the rlig feature:

feature rlig {
#ifdef VARIABLE

condition 140 < wght < 180;
sub dollar by dollar.bold;
sub cent by cent.bold;

condition 120 < wght < 180, 3 < wdth < 5;
sub dollar by dollar.bold;
sub cent by cent.bold;

#endif

} rlig;

This is a non-standard, Glyphs-specific extension variable feature syntax. (Thanks, Glyphs!)

The Adobe syntax looks like this:

conditionset bold {
    wght 140 180;
} bold;

conditionset boldcondensed {
   wght 120 180;
   wdth 3 5;
} boldcondensed;

variation rlig bold {
   sub dollar by dollar.bold;
   sub cent by cent.bold;
} rlig;

I've created a glyphsLib issue to track.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants