Glyphs as a Python Module


#1

EDIT
I want to run a shell script that includes a Glyphs python script, so is possible to import Glyphs as a module?
I’ve found a post where Georg says that is not possible to run glyphs ‘headless’.

I will try to explain better. What I’m trying to do is automate exporting from a shell script. I already have a python script that automates this task but it requires to
Glyphs be open, so via Apple script I managed to open the App and now I want to run the python script (is not saved in the Glyphs script folder). I was wondering if is possible via Apple script to ‘paste’ the python code in the Macro window or open the .py file with Glyphs and then run the code. For instance in Robofont when you open a .py file it opens a Scripting window.

Thanks in advance


#2

Did you see this: https://github.com/schriftgestalt/GlyphsSDK/tree/master/Glyphs%20remote%20scripts


#3

Thanks Georg I just founded after I sent the message, sorry for reposting.
I tried with your script but I get

from Glyphs import *
ImportError: No module named Glyphs

Am I missing something?


#4

Yes, I’ve missed to save the Glyphs.py in the same folder of the test script.


#5

How should I set ExportContainer key? In the commented code says “ExportContiner” looks like a typo but I tried in several different ways but It doesn’t work for me, I cant manage to export woff, woff2 and eot.
@GeorgSeifert could you please help me with this.

This is what I got,

for instance in font.instances():
    print "Instance:", instance
    instance.generate_({
        'ExportContainer': "'woff', 'woff2', 'eot'",
        'Destination': web_path
    })

#6

I haven’t looked at the interface for the remote scripts, but try the following:

  • Replace Destination with FontPath for the directory/folder path to put the exported font files.
  • And replace ExportContainer with Containers which should also be a list, e.g., [ 'woff', … ]

Hope that helps. I might be totally wrong about those details, though.


#7

Thanks, I tried what you suggested but no luck. :slightly_frowning_face:


#8

The exportContainer was not processed properly. I fixed it.


#9

So it will available on a next release of the app?


#10

I’ll upload a new version, soon.


#11

Hi Georg! Is the exportContainer fixed in the last update (2.6)?

Best!


#12

I think so. Please try and report if it isn’t working for you.


#13

Sorry for the late reply, yes It works great! Is wonderful to have this feature. Now I can chain processes in the terminal
Thanks!!