Automatically updating the font directory with revised OTFs (OS X)

Primary tabs

3 posts / 0 new
Last post
Matthew Butterick's picture
Joined: 28 Jul 2009 - 3:14pm
Automatically updating the font directory with revised OTFs (OS X)

When working on a font, I like to increment my source files with a two-digit version number (foobar 02.vfb, foobar 03.vfb) so I can generate test OTFs with a version number.

The annoyance is that after I generate, I always have to drag the new version into Font Book and delete the old versions manually (because Font Book resolves duplicates erratically, usually preferring older files).

In the past, I've tried to set up a Folder Action to process new fonts, but it takes too long for Folder Action to notice that I made a new file.

No more. Now I've discovered Hazel, which is a little $20 program (preference pane) that's basically a much more attentive version of Folder Actions. Which makes it actually useful.

I generate my test OTF to the desktop. (Because it's the easiest destination to navigate to from the FL generate-font dialog.) My Hazel script watches for OTF files to drop onto the desktop. If it sees one that was created in the last minute (and it will grab them within a few seconds of their appearance), it deletes the older versions of that font from my ~/Library/Fonts, and moves the newest version there. If Font Book is running, it will automatically notice the change.

What's cool about Hazel is that you can embed shell scripts in your sequence of folder actions. So in this case, to do the "delete older versions" magic, I made a little perl script that looks at my new font & deletes anything in my font folder with the same filename prefix.

You would want to adjust this for your naming scheme. (And as usual, be careful of any script with an rm in it.)


use warnings;
use strict;
use File::Basename;

# extract the filename from the pathname Hazel passes in
my $filename = basename($ARGV[0]);

# this matches a filename of the form:
# prefix version number (optional version suffix).otf
# like foobar 02a.otf
($filename =~ m/(.+?)(\d{2,3})(.*?)\.otf/);

# get the family name if it matched
my $familyname = $1;

# if there's no $familyname, abort
exit(0) unless $familyname;

# remove the fonts that have the same family name prefix
my $output = `rm ~/Library/Fonts/'$familyname'*`;

# Hazel continues after this, moving the new font into the directory


Blank's picture
Joined: 25 Sep 2006 - 2:15pm

Don’t install your test fonts at all. Just do all your proofing in Indesign and generate test fonts directly into /Library/Application Support/Adobe/Fonts directory using Ben Kiel’s font generator script, overwriting the old font. Indesign automatically detects new or changed fonts and loads them on the fly. This will you save many hours of time that would otherwise be wasted incrementing font versions, restarting applications, clearing font caches, rebooting, dealing with Fontbook, etc.

And increment your entire working directory instead of individual files. It’s faster and this way you also end up archiving the related files you create for Superpolator, UFO Stretch, notes you take, etc. If multiple users are working on a design they should increment each round of changes with a date/version number and their initials.

Matthew Butterick's picture
Joined: 28 Jul 2009 - 3:14pm

To each his own.

If you do things my way, you may like this trick.

If you don't, you won't.