googlefonts / googlefonts/glyphsLib

Error RE "weight" on master when using within Glyphs

Open
#845 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
201
Forks
56
Avg merge
17m
Merged PRs (30d)
1

Description

Maybe I'm approaching this the wrong way, but when trying to use `glyphsLib` within Glyphs 3 itself:

```
import glyphsLib
font = Glyphs.font
ufos = glyphsLib.to_ufos(font)
```

I get:

```
Traceback (most recent call last):
File "", line 5
File "__init__.py", line 67, in to_ufos
result = list(builder.masters)
File "builders.py", line 200, in masters
self.to_ufo_font_attributes(self.family_name) # .font
File "font.py", line 40, in to_ufo_font_attributes
self.to_ufo_names(ufo, master, family_name) # .names
File "names.py", line 23, in to_ufo_names
to_ufo_names_roundtrip(master, ufo)
File "names.py", line 48, in to_ufo_names_roundtrip
weight = master.weight
AttributeError: 'NSKVONotifying_GSFontMaster' object has no attribute 'weight'
```

I wonder if this is a problem with `glyphsLib` thinking in terms of Glyphs 2 with a version 3 font. In Glyphs 2, `GSFontMaster.weight` will be defined, but in Glyphs 3, there is an array of axes in `GSFont.axes` where weight will be referenced - weight is not special and doesnt exist on the master. So maybe it is checking for it. But I'm not sure.

Contributor guide

Open the contributing guide

Research direction

Start in names.py at to_ufo_names_roundtrip, where the traceback reaches master.weight, and inspect how to_ufos processes Glyphs 3 masters and axes. Reproduce the conversion with the provided Glyphs.font example; done means a Glyphs 3 font can reach UFO output without the AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.