googlefonts / gftools

Misc tools for working with the Google Fonts library
Apache License 2.0
243 stars 70 forks source link

AttributeError: 'GSLayer' object has no attribute '.5' #683

Closed clauseggers closed 1 year ago

clauseggers commented 1 year ago

If this is not a bug, then how do I find the culprit for this issue? In the bottom of the output it mentions position ‘158’, but 158 of what?

INFO:GFBuilder:Creating variable fonts from Playfair-2_1-Roman.glyphs
INFO:fontmake.font_project:Building master UFOs and designspace from Glyphs source
INFO:glyphsLib.parser:Parsing .glyphs file
Traceback (most recent call last):
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/glyphsLib/builder/tokens.py", line 290, in _get_value_for_layer
    return str(getattr(layer, value))
               ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'GSLayer' object has no attribute '.5'

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

Traceback (most recent call last):
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/glyphsLib/builder/tokens.py", line 93, in parse_number_token
    expression += self._get_value_for_layer(layer, m[1])
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/glyphsLib/builder/tokens.py", line 292, in _get_value_for_layer
    raise ValueError(
ValueError: Unknown glyph property '.5' at position 158

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/glyphsLib/builder/tokens.py", line 60, in parse_bare_number_value
    index = [metric.name for metric in self.font.numbers].index(number)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: '.5' is not in list

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

Traceback (most recent call last):
  File "/Users/claus/.local/bin/gftools", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/gftools/scripts/__init__.py", line 91, in main
    mod.main(args[2:])
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/gftools/builder/__init__.py", line 672, in main
    builder.build()
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/gftools/builder/__init__.py", line 207, in build
    self.build_variable()
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/gftools/builder/__init__.py", line 335, in build_variable
    output_files = self.run_fontmake(source, args)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/gftools/builder/__init__.py", line 389, in run_fontmake
    FontProject().run_from_glyphs(source, **args)
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/fontmake/font_project.py", line 840, in run_from_glyphs
    designspace_path = self.build_master_ufos(
                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/fontTools/misc/loggingTools.py", line 375, in wrapper
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/fontmake/font_project.py", line 223, in build_master_ufos
    designspace = glyphsLib.to_designspace(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/glyphsLib/builder/__init__.py", line 130, in to_designspace
    return builder.designspace
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/glyphsLib/builder/builders.py", line 334, in designspace
    list(self.masters)  # Make sure that the UFOs are built
    ^^^^^^^^^^^^^^^^^^
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/glyphsLib/builder/builders.py", line 230, in masters
    self.to_ufo_master_features(ufo, master)  # .features
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/glyphsLib/builder/features.py", line 55, in to_ufo_master_features
    ufo.features.text = _to_ufo_features(
                        ^^^^^^^^^^^^^^^^^
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/glyphsLib/builder/features.py", line 103, in _to_ufo_features
    strings.append(expander.expand(prefix.code))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/glyphsLib/builder/tokens.py", line 28, in expand
    self.parse_token()
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/glyphsLib/builder/tokens.py", line 48, in parse_token
    self.output += parser(m[1])
                   ^^^^^^^^^^^^
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/glyphsLib/builder/tokens.py", line 107, in parse_glyph_property
    return self.parse_number_token(token, layer)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/glyphsLib/builder/tokens.py", line 95, in parse_number_token
    expression += self.parse_bare_number_value(m[1])
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/claus/.local/virtualenv/gftools/venv/lib/python3.11/site-packages/glyphsLib/builder/tokens.py", line 62, in parse_bare_number_value
    raise ValueError(
ValueError: Unknown number token '$.5' at position 158
clauseggers commented 1 year ago

This issue has also been opened under glyphsLib https://github.com/googlefonts/glyphsLib/issues/914

RosaWagner commented 1 year ago

Yes indeed this is a glyphsLib issue. gftools builder is only wrapping fontmake and doesn't have control over these messages. Position 158 is a bit cryptic but looking at the overall message, it might be the line number in the features.fea file of the master UFO generated by glyphsLib.

I see Georg already submitted a PR to fix this so closing here.