Hi there,
I want to use python to edit *.glyph
file in *.glyphspackage
folder directly.
(for some batch processing, I hope to edit the raw files if it is possible.)
For example,
If 10th line in A.glyphs
is (50,500,l),
. (Denote a node coords and type in a shape).
I want to change it to (100,500,l),
. My script would be:
import os
Glyphs.font.disableUpdateInterface()
file_path = "Myfont.glyphspackage/glyphs/A_.glyph"
with open(file_path, "r") as f:
lines = f.readlines()
# print(lines[10]) #before: (50,100,l),
lines[10] = "(100,500,l),"
# print(lines[10]) #after: (100,100,l),
with open(file_path, "w") as f:
f.writelines(lines)
Glyphs.font.enableUpdateInterface()
I’ve found the A.glyph
has change immediately. However, the editview tab and Glyphs GUI window don’t. Only when I close the *.glyphspackage
file and reopen it can see the change I made.
I’ve tried to use disableUpdateInterface()
and enableUpdateInterface()
function to freeze the GUI before I edited and refreeze it later. But they’re useless.
How can I edit *.glyph directly and see the change in editview window immediately? Is there any useful API functions and method?
Thank you.