New: Command-line tool for Glyphs

We have a new command-line tool with which you can export Glyphs source files to OpenType fonts. This is what it looks like:

Install the tool with pip:

python3 -m pip install glyphs-cli

Once installed, you can use the glyphs command.

Exporting fonts

This command-line tool itself does not know how to export fonts. Instead, it uses the Glyphs app installed on your Mac. That way, the results are the same whether exporting from the Glyphs app or from the command-line tool.

# export using latest Glyphs 3 version that is installed on the Mac
glyphs export --app 3 SomeFont.glyphs

(The Glyphs app does not need to be running and is not opened when using this command.)

Further, the tool can select any other Glyphs version. If you have multiple Glyphs app versions installed, you can choose among them.

# export using a specific version
glyphs export --app 3.4 SomeFont.glyphs
# export using a specific build number
glyphs export --app 3432 SomeFont.glyphs
# export using a specific app
glyphs export --app '/Applications/Glyphs 3.app' SomeFont.glyphs

This allows you to edit files with one Glyphs version and use the tool to export the files using another Glyphs version. That can be useful in a team where different people might use different Glyphs app versions but you still want everyone to export using the exact same version.

When no --app option is given, the tool uses the Glyphs version with which the file was last saved:

$ glyphs export SomeFont.glyphs
using Glyphs 3.5 (3512)
...

Use the --format option to choose between PostScript/CFF-style (cff, default), and TrueType-style (tt) OpenType fonts:

# export .ttf files
glyphs export --app 3 --format tt SomeFont.glyphs

Use the --output option to export to a specific directory instead of the current directory:

# export font files to the Desktop
glyphs export --app 3 --output ~/Desktop SomeFont.glyphs
GitHub Actions sample workflow

If you use GitHub to host your font project, you can use the following workflow to create font files for every commit you push. Adapt as needed:

name: Export Fonts

env:
  GLYPHS_BUILD: "3516"

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
  workflow_dispatch:

jobs:
  export:
    runs-on: macos-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.x'

      - name: Preparation
        run: mkdir Output

      - name: Install glyphs-cli
        run: pip install glyphs-cli

      - name: Install Glyphs version
        run: glyphs version install $GLYPHS_BUILD

      - name: Export
        run: glyphs export -a $GLYPHS_BUILD -o Output *.glyphs

      - name: Upload artifacts
        uses: actions/upload-artifact@v4
        with:
          name: export
          path: Output/

Managing Glyphs versions

Use the glyphs version family of commands to list, install, and uninstall Glyphs versions:

# show installed versions
glyphs version list
# show installed versions and downloadable versions
glyphs version list --remote

# download and install a specific version
glyphs version install 3432
# download and install the latest version matching a version number
glyphs version install 3.3

# uninstall a specific version
glyphs version uninstall 3432
# uninstall all versions matching a version number
glyphs version uninstall 3.3

These commands do not install full Glyphs apps. Instead, they install just the part of a Glyphs app that is required for the tool’s usage. Therefore, less storage space is used for each installed version. The glyphs tool manages these versions for you. When using glyphs version uninstall, only these managed versions are uninstalled, not the Glyphs apps you have installed manually.

If you want to install a full Glyphs app that you can also use outside the tool, pass the --app option when installing:

$ glyphs version install --app 3.3
fetching index
downloading version Glyphs3.3.1-3343
######################################################## 100%
installing application /Applications/Glyphs 3.3.1-3343.app

Learning more

Ask the tool for help with --help at the end of a command. It will output all possible arguments, options, and subcommands:

glyphs --help
glyphs export --help
glyphs version --help
glyphs version install --help
...

Next steps

When anything is unclear or could be explained better, feel free to ask here on the forum. This tool is still in an early phase so I am sure there is plenty to be improved. One thing that is currently missing: If you run plug-ins such as filters on export, those are currently not supported yet.

It works best with recent Glyphs versions (3.3, 3.4, 3.5) and less well with older versions.

Currently, it’s available using Python’s pip, but we also intend to provide a direct download and maybe other package managers as well.

Exporting is the main feature of the tool now, but we could think about also offering other Glyphs capabilities. Let us know what kind of glyphs ... subcommands would be valuable to your workflow.

8 Likes

This is absolutely incredible. Amazing work, thank you!

1 Like

One thing I would really, really appreciate (in order to be able to use this) would be the possibility to run filters on the font before export. Such as nested component removal. Although I assume that these are applied when set as filter arguments in the instance definitions.

Is a more enhanced feature set planned? If so, what ideas are you thinking of?

While custom plug-ins are on the roadmap, they are a bit tricker to implement. Especially since most custom plug-ins are written in Python, which introduces further complexity. Still, should all be possible, I just need a good plan and more time.

Note that build-in export filters do work since no custom plug-ins need to be loaded for those.

There are many possibilities. I would be most interested in outside feedback in order to know whether my general direction for the tool aligns with users needs or if it would be better to focus on other areas.

For the export command, I would like to have a config file where you can configure the instances and export paths and other settings. A bit like a Glyphs project but tailored for a command-line tool. There is already the --config option, but it is not well documented yet and I still don’t have a clear idea how to best structure that configuration.

This sounds great. Essentially, this would be a Glyphs-native alternative to fontmake, which could use .glyphsproject files (or the settings in the Glyphs file) instead a of a designspace file.

As you mention, a config for the directory map would hé extremely useful. I have this set up in my own export plugin, as a YAML config.

In any case, I am very interested in utilising this, it’s just not yet useful to me. Keep us posted!

That’s interesting! That would be a huge improvement for CI/CD generated fonts and remove the dependency to fontmake and designspace format.
Looking forward to test it!

CI/CD is very much one of the focus areas for this tool. Have a look at the GitHub Actions workflow that I have included in the first post and adapt as needed. I am sure similar workflows would be possible on other CI/CD providers.