BubbleKern
Please consider subscribing to LWNSubscriptions are the lifeblood of LWN.net. If you appreciate this content and would like to see more of it, your subscription will help to ensure that LWN continues to thrive. Please visit this page to join up and keep LWN on the net.
At ATypI 2016 in Warsaw, Toshi Omagari presented an open-source tool he has developed to partially automate the repetitive task of generating kerning data for fonts. The program is called BubbleKern and, although it does not fully automate the kerning process, it may strike a balance that many font designers find useful.
Kerning traditionally referred to carving cutouts into the physical metal sorts for particular letters, Omagari said, which we would today refer to as negative sidebearings. It enabled letters with an overhang, like "f", which could otherwise not fit next to standard letters. The wood-type printing era used an approach more like what is done in digital type today, however. Many standard blocks would be cut down so that would fit together more closely. The visual gap between problematic pairs like "AW" is a common example; Omagari showed images of wood-type blocks cut down with carpentry tools to produce a better fit. That fine-tuning is akin to what designers do in digital type.
But, generally speaking, kerning today refers to any kind of
conditional spacing. Type designers regularly do kerning for standard
alphabetic fonts, while it is a far more complicated process for some
specialty fonts like those for typesetting mathematics. Most font
editors provide only a basic mechanism for kerning: there is a text
preview window, and the user can enter adjustments to change the
distance between a pair of letters, as many times as is necessary to
achieve an appropriate result.
Periodically, someone makes an attempt to automate or otherwise improve the kerning process in a font editor. Omagari showed screenshots of the oldest such tool he has found: Calamus Type Art, a 1989 program for the Atari that, against all odds, is still available for purchase today; the most recent update being 1999's version 2.0.
Coincidentally, the kerning tool in Calamus Type Art uses some similar steps to BubbleKern's approach, although Omagari noted that he only learned about the other program after the fact.
BubbleKern is implemented as a set of scripts for the Glyphs font editor. Using it requires three steps. First, the user creates a drawing layer called "bubble" and, for each glyph of interest, draws a shape that encloses the glyph. These bubbles, he said, are meant to represent the necessary space each glyph requires. Unlike sidebearings, which are a single signed value, the bubbles can take the shape and slope of the glyph into consideration. Drawing the bubbles is a free-form operation; they can include as many straight lines or curves as necessary.
Second, before the kerning step itself, the user first selects all
glyphs of
interest—running the script against every glyph in a large font
is generally regarded as a bad idea given the enormous number of
permutations. Finally, the script then reduces each bubble to a series of
horizontal, rectangular bands 20 points high. Since a standard
OpenType font is designed on a 1000-point grid, there are thus 50
bands per glyph. The script then compares pairs of selected glyphs,
moving them toward each other until there is a collision between the
bands. The adjustment required to make the bubbles touch is then
saved as a kern in the font source file.
The process is inevitably an iterative one, Omagari said; the user will want to edit the bubbles and re-run the kerning script. So BubbleKern provides a visual preview of the bubble layer. It is also possible to run the kerning step on a selected sample text rather than to generate all permutations for selected glyphs; that may also save time for some designers.
Several corner cases require special attention. Composite glyphs (such as accented characters) simply inherit the bubbles of their base glyphs (that is, the unaccented character). Glyph pairs that will not ever collide are a more problematic case. The period and quotation marks, for instance, probably require some kerning, but because they do not overlap at any horizontal band, would slide past each other. So BubbleKern's algorithm clamps the maximum possible kerning adjustment to be one half of the width of the narrower glyph in the pair. Omagari reports that this seems to be a sensible limit, and is hardcoded into the script.
But there are some unsolved problems as well, even ignoring the fact that sloppily created bubbles will generate poor results. First, if the user draws bubbles around the serifs on their glyphs, they may get unexpected results, because serifs usually extend almost all the way to the glyph's sidebearings. Thus, the user needs to clip bubbles at the sidebearings (even if that means the bubble is much thinner around the serifs than it is elsewhere). Another issue is that the script currently cannot make positive kerns, such as might be needed between W and a quotation mark or apostrophe. Finally, the script is limited to generate kerning values in the TrueType-style kern table format; users who want to produce kerning data in other formats (namely the GPOS table used by CFF-flavored OpenType fonts) will have to convert the results with another tool.
Omagari estimates that BubbleKern takes care of 70 to 90% of the kerning required when making a font. That is not a perfect solution by any means, but it also has side benefits. For example, it can catch glyph pairs that need kerning even when the designer did not notice them. And it could be extended to cover more situations, such as kerning trigraphs or kerning fonts in the Nastaliq writing style, where collisions can occur between glyphs that are several characters apart in the underlying string of text.
There have been other attempts to automate the kerning process
prior to Omagari's. Charles M. Chen's command-line tool Autokern,
for example, used related ideas. BubbleKern has one obvious
advantage over a program like Autokern, however: it can be integrated
into the popular font editor used by a rapidly growing number of
working font designers,
including integration with the on-canvas drawing tools. So far,
BubbleKern is only available for Glyphs (which is proprietary and runs
only on Mac OS X), but its Apache 2.0 license would
certainly allow it to be ported to other tools and platforms.
| Index entries for this article | |
|---|---|
| Conference | ATypI/2016 |