googlefonts / googlefonts/glyphsLib

unify loading of glyphs source into GSFont object

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

Description

we currently have two alternative ways:

1) instantiating a new GSFont object and passing a path to a .glyphs file

```python
from glyphsLib import GSFont
font = GSFont("MyFont.glyphs")
```

2) using the json-like `glyphsLib.load` (for a file or path,`loads` for a string) function

```python
import glyphsLib

with open("MyFont.glyphs") as fp:
font = glyphsLib.load(fp)
```

The two methods supposedly produce the same kind of object, however they seem to be calling different methods of `glyphsLib.parser.Parser`.

this is in `GSFont.__init__`:
https://github.com/googlei18n/glyphsLib/blob/0a86327a93b3f324f200e35a23f639db4ae58280/Lib/glyphsLib/classes.py#L3010-L3013

this is `loads` function:
https://github.com/googlei18n/glyphsLib/blob/0a86327a93b3f324f200e35a23f639db4ae58280/Lib/glyphsLib/parser.py#L255-L263

Contributor guide

Open the contributing guide

Research direction

Start by comparing GSFont.__init__ in Lib/glyphsLib/classes.py with load and loads in Lib/glyphsLib/parser.py, focusing on the Parser methods each path invokes. Exercise both loading examples and verify they produce equivalent GSFont objects and behavior; the issue is complete when loading from a path, file, or string uses a unified path.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.