Batch export

Hi Mark,

the brackets in the documentation of the .generate() method indicate that all parameters are optional, not that they need to be supplied in a list. If you skip everything, it will default to OpenType. And so will .generate('OTF') work.

Hi Yanone, I see. So there is no way to pass “WOFF” or “EOT” in there? Since this is my attempt in the first place.

setting the webfont formats as arguments is not possible at the moment. But you can define them as custom parameter (Webfont Formats)in the instance

But you’re going to implement it soon, right? :wink:
Anyway, I totally agree that they need to be available to the API at some point.

1 Like

Thanks, I’ll try to use this for a workaround so far.

Edit:
What is the syntax inside of the WebfontFormats CP in order to define woff and eot? I can get them only work either the one or the other, but not both. Separators I tried comma, semicolon, space.
Edit-Edit:
Got it. It needs to be separated by newLine when defined in the CustomParameter menu. This will then be converted to comma-separated.

Is it possible to catch errors in the .generate() ? I got it in a try … except, but it doesn’t go into the except if it has a problem on export (which might be something like the usual export error messages that come up when there is a problem with feature code or, or illegal kerning group names, or such)

The generate() method should return the error message if there is one, but it didn’t I fixed it.

Georg…
trying to use this script and it exports OTF right but the Glyphsapp keeps running the “exportation window” and if cancel the window (even because the exportation is done) it crashes. Any clue wheres why?
cheers!

Can you post the script you are using? Or how do you trigger the batch export?

OpenFonts = list(Glyphs.fonts)
Exporter = NSClassFromString("GlyphsFileFormatOTF").alloc().init()

for f in OpenFonts:
    Exporter.setFont_(f)
    FilePath = '/Users/andreydesouza/Desktop/test'
    result = Exporter.exportToURL_error_(NSURL.fileURLWithPath_(FilePath), None)
    print result

is it better if I use the .generate() method?
actually the small script works, but just keep running the exporting window.

I would suggest this code

FilePath = '/Users/georg/Desktop/test'

for f in Glyphs.fonts:
    for instance in f.instances:
        if instance.active:
            result = instance.generate(FontPath=FilePath)
            print result
1 Like

great… thanks! =D

Just reminding: It still does not give an Error.

I have a folder that contains hundreds of Glyphs files (all different families) and want to write a script that generates everything inside, including those in subfolders. Is there a way to go through Glyphs files in a folder and generate instances really quick? I don’t want to see Glyphs opening and closing files visually, which slows it down.

Yes there is. I think you can even run the binary on the command line.

I wonder about that too. Do you have any hints where to start fiddling around with running the binary? I searched the web without success, yet

I can launch the Binary, the Terminal window spits out some Python errors, that usually appear in the console on a Glyphs launch. But how can one control Glyphs now? Which language does the Terminal edit window expect from me?