Font Programming

This site devotes a special page to stacking diacritics, since that feature is a critical aspect of the font for Yukon use. The stacking page covers the what and why of stacking while this programming page refers to the how. Many people will be familiar with kerning. This is information which is programmed into a font that affects the relative spacing of pairs of characters. For the Yukon project, two other kinds of information have to be programmed into the font, postioning and substitution.

Positioning controls the horizontal and vertical placement of a glyph (character shape) in a context. For instance we might like a circumflex or caron diacritic to always be centred above a base letter regardless of how wide the base is, as in wide base ô and narrow base î. And we would like a second diacritic placed or stacked above a letter to not overlap the first diacritic but to be clearly visible above it. For instance, the Tagish sentence, "Her younger sister is making fire," without positioning looks like , and with positioning looks like . The grave overlaps the macron in the first example from Safari, the Mac OS X web browser, while the grave is above the macron in the second example from Babelpad on Windows (see below).

Substitution information allows an alternate glyph to replace a main glyph for a character in a particular environment. For example, when a diacritic is to be placed over an i, in most cases we would like the dot to disappear.When a user types i+grave, we would like to see something like ì, that is, a dotless-i with a grave diacritic. For this to happen, the font needs to be programmed so that a dotless-i is substituted for a dotted-i when followed by a diacritic. This substitution takes place only for display and printing. The underlying character codes (backing store) are not changed.

Windows Font Programming
The Microsoft strategy is to embed font positioning and substitution information within the font file. In OpenType fonts, this information is contained in two tables, a GPOS table for positioning, and a GSUB table for substitution. Microsoft provides a free tool to build this information into fonts called VOLT, Visual OpenType Layout Tool. The application has challenges for users but does work and was successfully used to program positioning and substitution into YNLCserif.

At the time of development, summer 2003, there were no Windows applications, like a word processor, which could test this programming in easy ways. Also, no off-the-shelf version of Windows was designed to work with these kinds of font programming. But with MS Office 2003, it is now possible to use Office Word and Internet Explorer to test the font tables. The descriptions which follow are old fashioned but may contain useful information.

With earlier work (pre Office 2003), several kinds of software were used in conjunction to test the font. First, an appropriate version of Uniscribe was needed. This is Windows software which is intended to process the programming in OpenType fonts so that applications do not need to. Also known by its Windows filename, usp10.dll, Uniscribe was available in countless versions, most of which would not work with positioning and substitution. The MS Office installers now take care of this and probably most font programmers can forget about it. It is perhaps best to check with the VOLT users community to see if newer versions are recommended for developers.

Babelpad is a basic text editor, like Notepad, which allows you to see on screen the positioning and substitution at work in one face of a font at a time. It also allows text input through Unicode values, which is essential unless one has a special keyboard. Babelpad is freeware developed by Andrew West, a scholar of East Asian languages and writing systems. I was not able to get the freeware application to print properly but it was absolutley critical to this project. Some things appear properly in VOLT but will not work with Uniscribe. With Babelpad it was possible to iron these out. In addition, Babelpad was used to construct HTML files (Babelpad screen) which could be displayed and printed in Internet Explorer 6 (IE screen). Explorer printed well but had trouble with refreshing the display. The first window-full would be fine, but scrolling down would bring up rows of greyed-out text which could not be restored to the intended appearance through any means. Despite the difficulties, it was possible to do the desired programming and test it using cost-free software. If Office 2003 does work properly with substitution and positioning in fonts, then it would be possible to simply test VOLT programming in MS Word.

Macintosh Font Programming
There are no Macintosh tools available for programming substitution and positioning information into a font which are as easy to use as Microsoft VOLT but this is not critical at this point in time. After completing the Windows programming on YNLCserif, and before attempting the Macintosh programming, the font was tested in TextEdit on OS X 10.2. Amazingly, the positioning appeared to be mostly working without special Macintosh programming (TextEdit text screen, TextEdit browser screen). I wondered if OS X 10.2 could somehow read the GPOS and GSUB tables. John Jenkins of Apple's typography unit kindly informed me that Cocoa programming environment generates accented forms on the fly. There is no GPOS support but they are looking into how they could provide it (email, September 27, 2003). GSUB support is also desirable. Cocoa does substitute dotless-i for i when a diacritic goes above, but the ability to add custom substitutions, like that offered in GSUB, is desirable.

It appears to be theoretically possible to at least add substitution logic to a Macintosh font, but fairly sophisticated programming skills are required. For instance, to program in a substitution, one needs to prepare a Morph Input File (MIF) containing a header, a class list, a state array, and an action list, then run ftxenhancer through OS X's Terminal on both the MIF and the font, and hope no errors were made along the way. The information is kept in a morx table. It does not appear possible to examine a morx table with any tool other than by hex codes, so the programming work of others cannot be easily used as examples. The Font Tools Release 1.0.0 (November 2001) contains a suite of command line tools for OS X 10.2 including ftxenhancer. In the documentation, The Apple Font Tool Suite (2002), p.29-40 discusses MIF files. The Apple Font Tool Suite Tutorial (October 2002), Lesson Four is on MIFs. More technical information on the morx table is in the True Type Reference Manual, chapter 6.

It is esthetically desirable to add some substitution logic for the YNLCserif font on Macintosh. The macron when used above the letter i is too wide. Similarly, the subscript marcron (macronbelowcmb 0331) when used below bar-l (lslash 0142) is too wide. On Windows, special narrower glyphs are substituted in these contexts through GSUB. The font is still readable on Mac without these substitutions.