Nameplate set in Sutro Deluxe and Initials from Parkinson. Your typeface could be next. Learn more.
Ads via The Deck
Commentary

An Introduction to RoboFab

Ben Kiel on May 4, 2005

Robofab-Map-ThumbRoboFab is a set of tools for eliminating repetitive tasks from the font design and production process. Version 1.1 was released earlier this year. This review is written for the type designer who is comfortable with FontLab and isn’t afraid of a little programming. While RoboFab can work on fonts without FontLab, RoboFab with FontLab is the main focus of this article.


A Brief History
RoboFab is a project started by Erik van Blokland, Tal Leming, and Just van Rossum (The RoboFab Consortium) at TypoTechnica 2003. All three had been working on utilities to make FontLab easier to script and use. In an effort to combine, rather than duplicate efforts, they initiated RoboFab. The first public release was in March of 2004.

What is RoboFab?
RoboFab is a collection of Python objects for working with fonts and glyphs. Like a set of Legos®1, RoboFab gives a type designer building blocks for making useful tools. Python2 is the scripting language used by both FontLab and RoboFab. It is a popular, powerful, and easy-to-use scripting language developed by Guido van Rossum (who happens to be Just van Rossum’s older brother). RoboFab adds to and enhances FontLab’s existing Python support.

The “Lego blocks” of Python are called objects. There are two main objects in RoboFab. The first is the Font object. This stores and manipulates things such as where glyphs sit in a font, the kerning and spacing of a font, and the font information (naming, copyright, etc). The other object is the Glyph object. This stores and manipulates each individual glyph in the font. RoboFab also has a set of objects that act as tools for font building. These include Pen objects and objects for creating dialogs.

RoboFab also introduces a new font format called UFO. Not intended for the end user like PostScript or OpenType, the UFO format is a production format, a way of representing a font in XML. With UFO, font design data is independent of a design application (like FontLab or Fontographer). Because font designs can have a very long life, the UFO format can save a designer from losing work when the original application in which the font was designed is discontinued (Fontographer). UFO, because it is a collection of text files, also allows fonts to be stored in databases or version control systems such as CVS. RoboFab includes a set of scripts to import and export UFO fonts into and out of FontLab.

The 1.1 release of RoboFab fixes several bugs from the 1.0 version and adds a few new tools. The most important additions and changes include a new Pen object for transforming glyphs, a new dialog that makes searching for a glyph in a large font much easier, and a rewrite of the interpolation method to make it quicker and more flexible. The documentation is also greatly improved.

What can RoboFab Do?
RoboFab is not a set of tools used to design a font; it is a set of tools used to automate repetitive tasks during type design and production. During the RoboFab sessions at TypoTechnica 2005, Tal Leming commented that anytime he finds himself doing a task a second time he instead writes a script to do it. By scripting repetitive tasks the designer removes the chance for human error. If one is dealing with a large font family this can save a lot of time when troubleshooting problems or correcting mistakes. Instead of spending time doing the same thing over and over a designer solves the more interesting problem of how to script the task. Once solved, the designer has a tool that eliminates repetition and gives him more time for design.

Examples
The easiest way of seeing the scope of what RoboFab can do is to look at a few examples.

The first example shows how RoboFab can quickly change information for a group of open fonts. Say you need to change the family name for a large group of fonts. Usually this involves opening each one, going to the font information dialogue, changing the name, and saving the font. This is an error-prone process. A RoboFab script can quickly and easily do this for you.

This script, either copy-and-pasted or downloaded, should be put in your FontLab/Macros folder after you have installed RoboFab3.

#FLM: Change family name on all open fonts

# This short example shows how easy it is
# to take user input and apply it to a font

# First, import the RoboFab objects that we will need
# This is done by simply asking for the objects that we
# will need from robofab.world. We need the AllFonts object
# because it is what will tell RoboFab about all the open fonts
# in FontLab. We also need a dialog to ask the user for the
# new font family name. This is the AskString object.

from robofab.world import AllFonts
from robofab.interface.all.dialogs import AskString

# After importing the AllFonts object, we'll make an instance
allOpenFonts = AllFonts()

# Now we will tell RoboFab to ask for a new family name
newFamilyName = AskString('New Family Name?')

# Lastly, we will change the family name of each open font

# The 'for font in allOpenFonts' line tells RoboFab to look at
# each font in allOpenFonts
for font in allOpenFonts:
# This is how we update the family name
font.info.familyName = newFamilyName

# A message telling the user that the changes have been made.
print 'All fonts updated with family name: ', newFamilyName

The script will open a dialogue asking for the new family name for all fonts that are open. Then it changes the family name for each font. Without comments, it is only seven lines long. It is much quicker to write seven lines of a script than it is to change the name of twenty fonts. As an added benefit, once the script is written it can be used again and again.

A new object in RoboFab 1.1 is the FilterPen. It makes transforming glyphs an easier task than it was in RoboFab 1.0. The following script demonstrates the threshold method of the FilterPen. This is useful for a quick clean up of an auto-traced font.

Copy and paste the following script or download it.

#FLM: Example of a FilterPen
# This example is a modification of the Threshold Pen
# example from the RoboFab website

# First import the objects that are needed
# In this case we need the Filter Pen and Current Font
from robofab.world import CurrentFont
from robofab.pens.filterPen import thresholdGlyph

# Tell RoboFab that the font we want to work on is
# the foremost in FontLab
font = CurrentFont()

# Set the value for the distance between points
d = 50

# Now go through the font, modifying each glyph
for glyph in font:
thresholdGlyph(glyph, d)
# It's best, when making changes to a glyph,
# to tell FontLab to update it
glyph.update()
# Same goes for the font when you've made changes
font.update()

print 'All done filtering your font!'

filterPen_sm.gif

Above, the results of the FilterPen script on a roughed-up glyph.

The threshold value for this example was set too high in order to demonstrate what the script would do; a lower value would produce better results. If the value is set to “one” the script will remove overlapping points.

This last script shows how RoboFab’s interpolation is more flexible than FontLab’s.

Copy and paste the following script or download it.

#FLM: RoboFab Interpolation Demo
# This example is a modification of the
# intro_InterpolateFonts.py which comes with RoboFab

# Import OpenFont, which allows the user to open a font file
# Also import RFont, so that a new font can be created
from robofab.world import OpenFont, RFont

# Get the two masters for the interpolated font
minFont = OpenFont(None, "First font")
maxFont = OpenFont(None, "Second font")

# Make a new font to hold the interpolated font
interpolatedFont = RFont()

# RoboFab's interpolation is powerful in that it can interpolate
# the horizontal and vertical dimensions of a glyph separately.
# In this case we'll interpolate the horizontal at 50% between
# the two fonts and the vertical at 80% of one, 20% the other
interpolatedFont.interpolate((.5, .2), minFont, maxFont)

# Update the new font
interpolatedFont.update()

interpolation.gif

Above, two masters on the left and the product of the interpolation on the right. The horizontal direction was interpolated at 50% of the masters and the vertical was at 80% of the first master and 20% of the second.

Unlike FontLab, RoboFab will interpolate a font with different values for the horizontal and vertical directions. It also never add points to the masters as FontLab sometimes does. If a font has glyphs that do not match in point structure they will not be interpolated. The rest of the font, however, will be.

Conclusion
If you find yourself frustrated with repetitive tasks in FontLab, RoboFab is the best tool to quickly script FontLab. Despite having to wade through a bit of programming, the included examples and documentation make it easy to learn. After mastering the basics of Python, writing simple scripts is easy and creating complex scripts is as painless as can be. RoboFab is a tool that is worth a look, and best of all it is free.

Useful URLs
Pyrus how-to on installing Python in FontLab
How to install RoboFab
RoboFab How-to’s

1 The Lego® and type design connection isn’t without precedent. See Mark Simonson and his actual Lego project.

2 A good introduction to Python programming can be found for free in the Python documentation

3 Installing RoboFab is fairly straightforward. The installation instructions are clear and well written.

Ben Kiel is a typeface designer and educator. He runs Typefounding, a typeface design and production studio in Saint Louis, Missouri. Previously he was a typeface designer at House Industries. He teaches at Washington University in Saint Louis and the Type@Cooper program in New York City.

11 Comments

  1. Dan Reynolds says:

    Thanks for the article, Ben & Typographica! I’ve sat through two separate introductions of RoboFab now, and this review is the first time that I’ve been able to begin to understand how the scripts mights be usable in day to day situations. I guess that I’m just scared of computer programming. Or maybe really slow.

    RoboFab is not a set of tools used to design a font; it is a set of tools used to automate repetitive tasks during type design and production.

    I know that this is a stupid question, but what are some of the repetitive tasks that occur in type design and production? Other than the ones you mentioned in your review?

  2. Tal Leming says:

    Well, a quick perusal of my FontLab scripts folder turns up the following (in no particular order):

    - building accented and composite glyphs
    - moving glyphs between fonts
    - outline operations (removing overlap, correcting path direction, etc.)
    - generating fonts
    - point operations (moving, aligning, removing, etc.)
    - manipulating metrics
    - manipulating kerning
    - setting encodings
    - setting unicode values
    - setting the various bits of naming data
    - etc.

    And those are just my FontLab scripts. As Ben mentioned, RoboFab also runs outside of FontLab. I have many, many scripts that work in NoneLab to do things such as handling complex interpolation schemes, automagic OpenType feature generation, merging and exploding glyph sets, etc.

    I don’t think I could survive without being able to program these things. I’d rather spend 2 hours drawing than spend 2 hours manually setting naming data.

  3. Paul van der Laan says:

    I know that this is a stupid question, but what are some of the repetitive tasks that occur in type design and production? Other than the ones you mentioned in your review?

    Design a complete typeface and you’ll find out. Or better … build a typeface family. ;)

  4. Dan Reynolds says:

    Design a complete typeface and you’ll find out. Or better … build a typeface family. ;)

    Hey, I’m working on it ;-)

  5. Dan Reynolds says:

    Thanks for the list, Tal.

  6. pablo honey says:

    building accented and composite glyphs
    - moving glyphs between fonts
    - outline operations (removing overlap, correcting path direction, etc.)
    - generating fonts
    - point operations (moving, aligning, removing, etc.)
    - manipulating metrics
    - manipulating kerning
    - setting encodings
    - setting unicode values
    - setting the various bits of naming data
    - etc.

    won’t FL5 make doing a lot of this easier?

  7. Dan Reynolds says:

    What about stem width? Could I write a script to control stem width, to equalize it across a font (or a set of glyphs)?

  8. What about stem width? Could I write a script to control stem width, to equalize it across a font (or a set of glyphs)?

    Consider this: in a collection of coordinates of online and offline points that defines a lettershape: what is a stem? If you can solve that, you can write a RoboFab script to unify them.

    Seriously, this is not the kind of script that you would make when you’re starting with Python scripting in FontLab. The examples that Tal mentions are much easier to do and will save a lot of work too.

    The essence (for me at least) to use RoboFab is not to add features that might be implemented in FL5, but to tailor FontLab to my workflow and to chain various operations in one script.

  9. Ben Kiel says:

    What Paul said is spot on. If you can clearly define something you can script it. For me, scripting starts with a sheet of paper and a pencil. I make a list of each step that has to be done to accomplish a task, break that list into each decision that has to be made, then I open BBEdit and start scripting. If you know all the decisions and steps that have to be made, you’ve written most of your script without touching a computer.

  10. Ian Carter says:

    Now that Fontographer is no longer supported, is it possible to open a .fog file in FontLab, or with RoboFab?

  11. Hi Ian. I think you can convert with FogLamp.

Post a Comment

Comments at Typographica are moderated and copyedited, just like a “Letter to the Editor” in a newspaper. Abusive or off-topic comments will not be published. Compliments are appreciated, but will not be published unless they add to the conversation. Thank you!

Recently Commented
Colophon

Typographica is a review of typefaces and type books, with occasional commentary on fonts and typographic design. Edited by Stephen Coles and designed by Chris Hamamoto. Founded in 2002 by Joshua Lurie-Terrell. Relaunched in 2009 by Coles and Hamamoto.

Set in Bureau Grot by Font Bureau, Nocturno Display by Nikola Djurek, Fern (unreleased) by David Jonathan Ross, and JAF Bernini Sans by Tim Ahrens.

Brought to you by this month’s nameplate sponsor, FontShop, MyFonts, FontFont, Wordpress, Fused, and the letter B. Read our editorial policy.

Elsewhere