|
|
Log in / Subscribe / Register

BubbleKern

Please consider subscribing to LWN

Subscriptions 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.

By Nathan Willis
September 21, 2016

ATypI

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 [Toshi Omagari] 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 [BubbleKern bubbles] 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
ConferenceATypI/2016


to post comments

Include the bubbles in the font?

Posted Sep 23, 2016 9:33 UTC (Fri) by epa (subscriber, #39769) [Link] (2 responses)

I see that the program translates the 'bubbles' drawn by the user into a series of kerning values for each possible pair of characters (or at least each pair of interesting characters). These numbers are stored in the font file but the 'bubble' information is not, the article seems to imply. But this means that if you have an existing font and you want to add some new characters to it, you effectively have to start from scratch and draw bubbles again. Why not include the information as an extra section in the font file itself?

Otherwise fonts end up with 'source code' which includes the information used by the font's designer, and an 'executable' version which only has the information needed to render them, but isn't easy to edit further. This distinction is unavoidable for compiled programming languages, but it would be better to avoid it for font files if possible.

Moreover, if the bubble data is included then some future font renderer might be able to deduce kerning automatically for cases where a value is not specified in the file (for an unusual pair of characters, or for mixing two fonts).

Include the bubbles in the font?

Posted Sep 23, 2016 14:06 UTC (Fri) by n8willis (subscriber, #43041) [Link] (1 responses)

Why not include the information as an extra section in the font file itself?

Because that would entail altering the specification for the binary font file format which, as the OT 1.8 article suggests, is not an easy nor a quick process. Toshi did end his talk by suggesting something along those lines, but from context it was clear that this was more of an 'opening the conversation' suggestion than anything else.

Otherwise fonts end up with 'source code' which includes the information used by the font's designer, and an 'executable' version which only has the information needed to render them, but isn't easy to edit further.

This is already the case for every font editor's native file format; no editor works on end-result binaries as its preferred form for alterations.

Nate

Include the bubbles in the font?

Posted Sep 23, 2016 14:29 UTC (Fri) by pabs (subscriber, #43278) [Link]

An LWN article about font formats (source and binary) would be very interesting.


Copyright © 2016, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds