-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Saving to .glyphspackage format? #953
Comments
Re: question 3... I guess I could save to .glyphs format, then convert that to a glyphspackage. 🤔 I wonder if I’d lose any data that way. There’s one way to find out, I guess! |
We haven't implemented writing .glyphspackage yet (though it should not be too hard in theory). |
Ah, awesome! I hoped someone might give a smart suggestion like this. Will try this out! In the long run, yeah, I would love to be able to interact with glyphspackage files more fully via glyphsLib, but for now my need is very simple. Thanks for sharing that insight! |
In case it helps anyone, here’s the code I ended up with. It seems to work well! """
USAGE:
python3 <path_to_script>/update-glyphs-source-version.py <path_to_glyphspackage>/familyname.glyphspackage <integer>
"""
import sys
import os
import openstep_plist
glyphsSource = sys.argv[1] # pass this in as first arg
versionMinor = sys.argv[2] # pass this in as second arg
# make path for fontinfo
fontinfoPath = os.path.join(glyphsSource, "fontinfo.plist")
# read the fontinfo.plist
with open(fontinfoPath, "r", encoding="utf-8") as fontinfo:
data = openstep_plist.load(fontinfo, use_numbers=True)
# update the data from passed-in arg
data['versionMinor'] = int(versionMinor)
# write to the fontinfo.plist
with open(fontinfoPath, "w", encoding="utf-8") as fontinfo:
# the extra args keep things closer to the formatting from GlyphsApp
openstep_plist.dump(data, fontinfo, unicode_escape=False, indent=0, single_line_tuples=True)
# print the update
print(f'Updated {data["familyName"]} with version {data["versionMajor"]}.{str(data["versionMinor"]).zfill(3)}') |
hm seems like openstep-plist writer always escapes newline characters and writes multi-line strings as a single line. There seems to be no option to pass through literal newlines: I think glyphsLib only uses openstep-plist to parse, but not also to dump. |
Okay, thanks for confirming! I had explored the options, but wasn't getting closer. I appreciate your help here! |
If I remember correctly, once upon a time Glyphs.app would write multiline strings (e.g. features) with the newline escaped, even using octal codes |
For simple changes like this, you could just read the file as a string and search and replace on it. That would keep the rest of the file unaffected. |
Ah, yeah, I guess I'm basically doing search and replace to fix things after changing them, so I could simplify it and just add the data the first time in glyphs, then search and replace only that. |
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 #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:
Unfortunately, running it currently gives this result:
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:
Thanks so much for any insights and/or ideas!
The text was updated successfully, but these errors were encountered: