glyph_data has contradictory types
simoncozens opened this issue · 4 comments
glyphsLib.builder.to_ufos
takes a glyph_data
parameter which is (a) passed to preflight_glyphs
, and (b) passed to UFOBuilder
.
In preflight_glyphs
, glyph_data
is interpreted as:
glyphsLib/Lib/glyphsLib/builder/__init__.py
Lines 170 to 171 in 8698f2c
So it's a GlyphData
object. However, in UFOBuilder
, it is described as
What does that mean?
glyphsLib/Lib/glyphsLib/builder/builders.py
Lines 187 to 194 in 8698f2c
Oh, it's a list of paths.
It's historically been a list of paths, but now if you pass a list of paths, preflight_glyphs
crashes because it's expecting a GlyphData
object:
File "/Users/simon/work/noto/math/venv/lib/python3.12/site-packages/glyphsLib/builder/transformations/propagate_anchors.py", line 67, in propagate_all_anchors_impl
anchors = anchors_traversing_components(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/simon/work/noto/math/venv/lib/python3.12/site-packages/glyphsLib/builder/transformations/propagate_anchors.py", line 157, in anchors_traversing_components
if layer.anchors and _get_category(glyph, glyph_data) == "Mark":
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/simon/work/noto/math/venv/lib/python3.12/site-packages/glyphsLib/builder/transformations/propagate_anchors.py", line 113, in _get_category
or glyphdata.get_glyph(
^^^^^^^^^^^^^^^^^^^^
File "/Users/simon/work/noto/math/venv/lib/python3.12/site-packages/glyphsLib/glyphdata.py", line 121, in get_glyph
attributes = _lookup_attributes(glyph_name, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/simon/work/noto/math/venv/lib/python3.12/site-packages/glyphsLib/glyphdata.py", line 164, in _lookup_attributes
data.names.get(glyph_name)
^^^^^^^^^^
AttributeError: 'list' object has no attribute 'names'
ouch, my bad.
I think we should avoid re-parsing it twice; if it's a list of str, interpret as paths as before, if it's already a GlyphData object, use as is
@simoncozens let me know if you are working on a fix already, so we don't duplicate work
Not planning to work on in for the forseeable.
ok i'll fix that thanks