RoboFab 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.
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.
#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!'
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()
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.
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.
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.