Extending Glyphs

Tutorial
by Rainer Erich Scheichelbauer
en fr zh

29 September 2020

It is easy to extend Glyphs: tap into the realm of existing scripts and plug-ins, or even write your own extension. It’s easier than you may think.

Basically there are two ways of extending the functionality of Glyphs: with scripts and with plug-ins. Both may require additional installations called modules. So let’s first get our Glyphs prepared, so you can extend it any way you want it. Don’t worry, this part you only have to do once.

Modules

Go to Window > Plugin Manager to open the Plugin Manager. This is the place where we install and uninstall all our extensions. Many scripts require Vanilla and pretty much all extensions need Python 3, so I would definitely recommend to install those:

While you are at it, you can also install the other modules listed there. True, relatively few extensions need FontTools and RoboFab, but it doesn’t hurt to have them, and what’s done is done.

Preferences

In Glyphs > Preferences > Addons, go to Python version pop-up menu, and make sure a Python version marked ‘(Glyphs)’ is selected:

In any event, after installation of any of these modules and setting the preferences, we recommend to restart the app, so all changes can take effect.

Scripts

Typically, scripts are small pieces of Python code that do one or two particular things well. They are stored in text files with a .py ending in a special folder called Scripts inside of Glyphs’ Applications Support folder, somewhere deep in the guts of the macOS Library. Glyphs will load and display all scripts in the Script menu. The submenus in that menu replicate the subfolder structure of that Scripts folder.

Scripts are quick and easy to write. Even if you have never coded before, you can learn basic scripting in one afternoon. They are also easy to install and their installation does not require a restart of the app.

Installing scripts: Plugin Manager

There are two ways of installing scripts. First, with an easy one-click install through Window > Plugin Manager > Scripts. Just browse through the available script collections, and pick the ones you want:

After that, you can reload the Script menu by holding down the Option key and simultaneously choosing Script > Reload Scripts (Cmd-Opt-Shift-Y). And voilà: next time you open the Script menu, the newly installed script collection is available already:

Here is the takeaway: script collections installed through the Plugin Manager (as described above) are kept up to date automatically. Every time you start Glyphs, and your Mac is connected to the internet, it will check if you have the latest version and update your installation if you haven’t done that already.

Manually installing scripts

The second way of installing scripts is by manually placing them inside the Scripts folder. The quickest way to access that folder, you guessed it, is to run Script > Open Scripts Folder (Cmd-Shift-Y). You can organize script files in subfolders, which will appear as submenus in the Script menu. Once you are done, do not forget to hold down the Option key again and choose Script > Reload Scripts (Cmd-Opt-Shift-Y).

Needless to say, manually installed scripts cannot be kept up to date automatically. Instead, you will have to manage them yourself.

Running scripts

Run scripts by simply choosing them from the Script menu. If you are not sure what a script does, hold your mouse over its menu entry for a second, and a tooltip will appear, describing what the script will do:

If it looks like the script has not done anything, the script may have run into an error. In that case, look in the Macro Window (Window > Macro Panel, Cmd-Opt-M) for error messages. They may give you a clue as to what went wrong. If you find a message that says something like this:

ModuleNotFoundError: No module named 'vanilla'

… the script requires something called a module. See the section called ‘Modules’ further above.

Plug-ins

With plug-ins, coders can dig deeper into the ecosystem of Glyphs, and do more advanced stuff. Though most plug-ins will show up in Filter and View, they can appear in any menu or even show up as palette in the right sidebar. Plug-ins are a bit more challenging to make still no biggie though, and different from scripts, they require a restart after installation or update.

Installing plug-ins through the Plugin Manager

Similar to scripts, you can install plug-ins with a single click in Window > Plugin Manager. Simply pick the Plugins section, browse through the plug-ins, and click on the Install button to install it. Or, if it is already installed, click on the Remove button to, well, you guessed it: remove it. That’s it.

Manually installing plug-ins

Commercial third-party plug-ins like Tim Ahrens’ essential RMX Tools (a.k.a. ‘Font Remix Tools’), the amazing LetterInk, or Makkuk’s LayerWhale for recording your design process, or one of Mark Frömberg’s many cool plug-ins: they come with their own instructions. Usually, you can simply double click the plug-in file, and Glyphs will ask you if you want to install it:

Simply confirm the dialog by pressing Install, then restart the app, and the plug-in will be active and available. You can find a selection of third-party plug-ins on the Resources page.

Show your love

Like a script or plug-in? Why not treat the developer to a coffee?

Almost all of the scripts and plug-ins in the Plugin Manager are available for free. Some developers, however, have donation links next to the URLs of their most popular items in the Plugin Manager. A click on the icon takes you to their micropayment page:

Consider how much better an extension made your life and show your appreciation. 💝

Advanced options

There are more ways to customize your experience of extending Glyphs, especially if you need to manage foundry-specific installations. In any event, this chapter is for specific environments and advanced Terminal acrobats only. So do not worry if the following does not make any sense to you, because it probably does not apply to you.

Your own Python 3 installation

You can brew your own Python 3 installation and use it within Glyphs. Simply pick your home-made Python from the pop-up menu in Glyphs > Preferences > Addons > Python:

Then restart Glyphs, and you are all set.

Wait, not quite. There actually is one more thing. If you use a different Python than the one offered to you in Plugin Manager, you are lacking an additional Python module called pyobjc. Try this in Terminal:

pip3 install pyobjc

And now it should work. You may need to restart the app once more.

Your own Plugin Manager content

Let’s say your foundry has custom scripts, plug-ins, and/or modules that need to be made available to everyone in the company. You have two options: either you publish them under an open-source license on GitHub and let us know about it. Then we will add them to our Glyphs Packages repository on GitHub, and a minute later, they are part of the Plugin Manager.

Or, especially if it is proprietary or top-secret code that cannot be published, you can set up your own packages list! It is easy: Go to Glyphs > Preferences > Addons again, and in the Alternate Plugin Repos field, add the URL for a publicly reachable .plist file that contains the scripts, plug-ins and modules you want to distribute to your co-workers.

All you need to do is set up and maintain that .plist file, and make your colleagues enter that URL in that field in Glyphs > Preferences > Addons. That’s it. Next time they open Window > Plugin Manager, they can access the additional extensions.

Your own scripts and plug-ins

Have not found that script or plug-in that fits your project? Why not write your own?

In case you have not coded before, let me tell you that Python is a great first scripting language. You can get started in an afternoon or two. No kidding. Read through the Scripting Glyphs tutorials. The first three are super-easy. After that, admittedly, it does get a little challenging. But you know what, others have done it before, and once you get the hang of it, it is hard to stop.

Once you are ready, you can continue with writing plug-ins. That will take you one step further, and you’ll feel so much more powerful.


Update 2020-10-20: Completed unfinished sentences (thanks Nathalie).