googlefonts / googlefonts/glyphsLib
Saving to .glyphspackage format?
- Dominant language
- Python
- Stars
- 201
- Forks
- 56
- Avg merge
- 17m
- Merged PRs (30d)
- 1
Description
It is awesome that glyphsLib (and fontmake) now support .glyphspackage files, as they are really nice for version control.
However, it looks like so far, glyphsLib only supports reading from .glyphspackage files (thanks to https://github.com/googlefonts/glyphsLib/pull/803), but not writing back to them.
I am hoping to increment the version number of a glyphspackage source during a build process, so I would love it if glyphsLib could write to the new format, too.
As an example, here’s some Python I’m trying to use:
```py
import sys
from glyphsLib import GSFont
glyphsSource = sys.argv[1]
versionMinor = sys.argv[2]
font = GSFont(glyphsSource)
font.versionMinor = int(versionMinor)
font.save(glyphsSource)
```
Unfortunately, running it currently gives this result:
```sh
▶ python source/01-build-scripts/helpers/update-glyphs-source-version.py source/familyname.glyphspackage 2
Traceback (most recent call last):
File "/Users/stephennixon/type-repos/familyname/source/01-build-scripts/helpers/update-glyphs-source-version.py", line 11, in
font.save(glyphsSource)
File "/Users/stephennixon/type-repos/familyname/venv/lib/python3.11/site-packages/glyphsLib/classes.py", line 4533, in save
with open(path, "w", encoding="utf-8") as fp:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
IsADirectoryError: [Errno 21] Is a directory: 'source/familyname.glyphspackage'
```
So, partly I am just filing this issue as a feature request, in hopes that saving to glyphspackage might get support soonish.
I do also have two questions:
1. Have I just missed something, and is this possible already?
2. If this isn’t a feature yet, realistically, is this likely to be supported soonish? Or, is it a larger scope of work / not really a priority right now? (It’s all good either way, I’m just trying to plan for a couple of projects.)
3. If it isn’t likely to happen soon, what might be a good way to handle this basic goal (incrementing versions for each build)? I could just use FontTools ttLib or font-v to write versions to font binaries only, or generate UFOs as a step of my build and edit the version number there... but is there another option that I might be missing?
Thanks so much for any insights and/or ideas!
Contributor guide
Research direction
Start at glyphsLib/classes.py, where GSFont.save opens the target path, and trace the existing .glyphspackage reading support. Check how the package format is represented and how the versionMinor example should save back to it. Done means the example no longer raises IsADirectoryError and the saved package can be read again.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100