Command-line tool for Glyphs

@FlorianPircher Could you add support for passing arguments to scripts via glyphs-cli? For example:
glyphs run SomeScript.py --args arg1 arg2 --input SomeFont.glyphs

1 Like

That sounds like a fine idea. I think an argument of two dashes -- is a common way to spell “pass the remaining arguments along unchanged”, like:

glyphs run SomeScript.py -i SomeFont.glyphs -- arg1 arg2 arg3
1 Like

@FlorianPircher Thanks! That would be very useful for me. I’m looking forward to using this feature.

CLI version 0.6.0 is out. Upgrade with pip3 install --upgrade glyphs-cli

This upgrade brings better compatibility with Glyphs 4 (some features require the next beta of Glyphs 4 to work as expected) and makes glyphs run a better Python code runner:

  • arguments after -- are passed along to the script in sys.argv
  • -c and -m work like with the regular python3 command
  • sys.pyth and __file__ are set correctly

So, now you can write commands like the following:

glyphs run SomeScript.py -- arg1 arg2 arg3
glyphs run -c 'print(Font.familyName)' -i SomeFont.glyphs
glyphs run -m somemodule
1 Like

After switching to 0.6.0, I get this error for all projects :

RuntimeError: glyphs export failed for 'XXX.glyphspackage'.
exit code: 1
stderr:
Error: Failed reading font /Users/hugojourdan/XXX.glyphspackage.

Do you have the Glyphs 4 beta installed? Try running with glyphs run -a 3 ... and see if that works.

No Glyphs 4 installed. It was working with previous cli version.
We are already using --app

Could you please run it with additional logs? Like so:

LOG_LEVEL=debug glyphs ...

Thanks for the report, I could reproduce and fix it. pip3 install --upgrade glyphs-cli

1 Like

or uv tool upgrade glyphs-cli

Hi, Florian!

When exporting a font that contains a variable instance in CFF format, glyphs-cli produces a broken variable otf file (fvar without CFF2). I expect that the util will simply ignore that instance, like the GUI version does.

glyphs export --app 3 --format cff --container standard otf-test.glyphs
glyphs-cli 0.6.1
Glyphs 3.5 (3531)

otf-test.glyphs (2.0 KB)

Glyphs 3 doesn’t know anything about CFF2. So variable fonts can only be exported as ttf. So the tool should catch that and throw an error.

glyphs export now skips variable CFF and logs a warning that an instance was not exported.

1 Like

Hi!

How is glyphs-cli intended to work with general plugins? For example, BetterVFExport. The plugin uses a start method to initiate a GSDocumentWasExportedNotification callback for post-export processing. However, in headless mode, start is never called.

I got it to work by a script that manually registers a callback, but what would be a best option?

Thank you.

The latest glyphs-cli version now invokes the start method of plug-ins just like the Glyphs app does.

However, some plug-ins do UI work in start and that does not work well with the CLI context. Often, the plug-in should still run fine, but plug-ins can also manually check whether they are running in the headless (no UI) mode, like in the CLI by checking for the GLYPHS_HEADLESS environment variable.

I have opened a pull-request on BetterVFExport that does this:

1 Like

Cool. Thanks, Florian!

Good evening, @FlorianPircher!

I understood that the glyphs-cli command-line tool requires the installation of Glyphs app, correct? I am asking it because of GitHub Actions workflow. I also read that Glyphs’ built-ins (for example, rough, rounded corners, etc.) are supported by this tool in reference to #4 by @SCarewe, #53 by @thundernixon, and #54. Am I correct?

I have questions:

  • Does the glyphs-cli tool need a Glyphs licence?
  • Can glyphs run execute the scripts from @mekkablue’s Glyphs-Scripts repository and @kylewaynebenson’s Simplify Shape?
  • Can this tool apply or execute the filters Roughen, Round Corners and Rounded Font during glyphs export? Can they be executed from a glyphs run script and then saved?
  • Can glyphs export execute Multiple Languages Syntax in the feature code identically to the app?

Not necessarily a full app installation. glyphs version install ... install the components that are needed.

There is a GitHub Actions sample workflow in the first post of this topic.

Yes, the glyphs CLI uses the Glyphs code which requires a license to run. For individual users, you can use your license for multiple Macs, including on servers.

It can run arbitrary Python code, so it can do whatever a script can do. I don’t think there is a nice API to run an existing script, but that is something we could add.

Yes and yes. Use the --plugins options to control which plug-ins are loaded.

Yes. It’s the same export process as in the app. There can be some differences in cases where the CLI needs to emulate the behavior of the app in reading/writing files. Let us know when you come across one and we’ll fix it.


Have a look at the project site, it lists and describes all options: Client Challenge

1 Like

How do I do it using only glyphs-cli through GitHub Actions? I gave a look at the documentation but did not find the licence option to activate.

Thank you for answering all my questions!

The Glyphs CLI is covered by your Glyphs app license. You do not need to install the license file on the server.