Adding OpenType Features in FontLab VI, Part 3: Housekeeping

In the last post I wrote about adding local language rules in the locl feature of my Protest™ font.

This post covers the things that were relatively minor for Protest. I need to give a caveat here. My font has specific needs (as any font does), and compared to text types is limited in scope. So while these features are minor for Protest, they could be a bigger deal for other fonts.

Here’s what I’m covering in this post in the feature order for Protest (in bold):

  1. script language specific forms (locl)
  2. fractions (frac, numr, dnom)
  3. ordinals (ordn)
  4. all caps (case)
  5. various alternates (calt, salt, ss01, ss02, ss…)
  6. ligatures (liga, dlig)
  7. manual alternate access (aalt)

Fractions

When typing fractions, one normally types a number followed by a slash, followed by another number (e.g.—3/4). This doesn’t look quite like a fraction. What we’d prefer to see is smaller numbers more vertically stacked, a numerator over a denominator with a proper fraction slash in between. Fraction features are how we deal with this aesthetic issue using OpenType.

Tal Leming’s OpenType Cookbook article covers a couple of ways to handle fractions. These are predicated on the idea that the font has numerator (small, somewhat superscript) and denominator (small, kind of subscript) versions of all the numbers. If this was the case for Protest, then I would have numr and dnom features. Buuuut… I don’t.

Protest is a display font meant to be used at large sizes in certain contexts. At this point, I don’t anticipate the need for extensive fractions, so Protest has limited small numbers, just 1, 2, 3, and 4.

Since this is the case, I’m just concerned with the more common fractions: ½, ⅓, ¼, ⅔, and ¾. These only require numbers 1–4.

All I need to do in this case is use a ligature substitution. A ligature substitution (also called a GSUB LookupType 4) replaces multiple glyphs with one glyph. The syntax is basically sub <glyph series> by <glyph>; where the glyph series is the number, a slash, and another number, and the glyph replacing them is a single fraction glyph.

So for Protest, if someone has the fractions OpenType feature turned on, whenever they type in a 1 then / then 2, I want it to become a ½. The same is true for ⅓, ¼, ⅔, and ¾. I’ve created these five fractions using the fraction slash, superscript 1–3, and subscript 2–4. These are their own glyphs, and they’re easy to generate using FontLab VI.

In FontLab’s menu, go to Font > Generate Glyphs. In the Custom tab, the recipes are pretty straightforward. (For more on glyph generation in FontLab VI, see my earlier post.) In the example below, uni2082 is the subscript 2, uni2083 is the subscript 3, and uni2084 is the subscript 4. Each of the “subscript” letters actually sit on the baseline in Protest.

I can finesse these after generation to make sure the spacing is right.

Once I have the fractions, the feature is also very straightforward:

feature frac { # Fractions
    sub one [slash fraction] two by onehalf;
    sub one [slash fraction] three by onethird;
    sub one [slash fraction] four by onequarter;
    sub two [slash fraction] three by twothirds;
    sub three [slash fraction] four by threequarters;
} frac;

The [slash fraction] above is a glyph set comprised of either the slash glyph or the fraction slash glyph. So if the user types either one the substitution will still occur. Ta-da!

Skipping sups, subs, and figures

At this point in the feature order, Tal Leming advises putting in the superscript, subscript, and figures features. Protest doesn’t contain superscript or subscript glyphs in any meaningful quantities, so I’m not including these features. It also only has one kind of figures (proportional lining figures), so there is no need for the figures feature.

Ordinals

Ordinals (like the superscript st in 1st) in Protest are comprised of only the feminine ordinal ª and the masculine ordinal º for languages like Spanish and Italian.

This is a feature the user turns on as needed in OpenType, so I don’t have to worry about it being language specific.

This feature is a basic one to one substitution (GSUB LookupType 1).

feature ordn { # Ordinals
    sub a by ordfeminine;
    sub o by ordmasculine;
} ordn;

Caps

Protest contains a lot of diacritics. These glyphs can be generated as the user types by using combining diacritic marks. Not all marks are the same for each case, however. The uppercase glyphs have diacritics that fit better within a confined vertical space so they don’t crash into descenders from the line above. If I want these special diacritics to combine with uppercase letters in certain contexts, I need to specify that in the case feature:

feature case {
    sub @diacr by @diacr.case;
} case;

In this instance, I don’t need to make any sort of contextual GSUB LookupType 5 substitutions, because the implementing software knows it’s checking this specific feature in uppercase instances.

I simply substitute the diacritic class with the uppercase diacritic class. This reminds me that I need to declare that class in the Classes panel in FontLab.

I simply select all the lowercase diacritic marks and hit the + in the Classes Panel. Then I change the name to “diacr” (my arbitrary name choice—it could be named Mxyzptlk if I wanted, but diacr is descriptive but not longer than I need). Then I do the same for the uppercase diacritics, and name the class “diacr.case”.

Note: these classes must have the same number of items, and their respective diacritical marks must be in the same order. The GSUB LookupType 1 substitution looks at the sets, then compares and substitutes the contents in order. If I have sets [a, b, c, d] and sub by [A, D, B, C], then a maps to A, but b maps to D, c maps to B, and d maps to C. I can make sure the diacr and diacr.case classes have the same number and order in the Classes panel.

Ligatures

I’m covering ligatures here because my alternates… took a while. And there’s a story to go with them. I’ll cover alternates in the next post. The reason ligatures come after alternates is that if I had ligated characters, they would read as a different glyph, and wouldn’t be detected properly by contextual alternates looking for the component characters of my ligature glyph.

For example, say I turned f and i into an fi ligature glyph. When it came time to switch an f followed by an i into f.ss01 followed by i.ss03, for instance, then the font would see the fi ligature and change neither. (This isn’t as big a deal here, but it can go really wrong in a number of other situations.)

The nice thing is, Protest has limited ligatures—just tt. Because of the the shape of the f, I don’t need fi, fl, ff, ffi, ffl, fj, or any of those other f ligatures. Why do tt and not ff, you ask? Because when I’m drawing a protest poster and draw my t’s, I’ll draw them one at a time, but the crossbars seem to touch (or want to touch) naturally. While for some reason the same is not true of my f’s. That and it just looked better this way.

For this ligature I use the same GSUB LookupType 4 that I used for the fractions, but with two t’s subbed by the tt ligature. There’s one big difference though. Ligatures need to come after my alternates, which means I will be dealing with pairs like t.ss01 and t.ss02, or t.ss03 and t.

I’ve actually made alternate tt ligatures as well, just like my t’s, so there are 4 total: tt, tt.ss01, tt.ss02, and tt.ss03. So I want to replace a sequence of two t’s with the tt ligature in the same stylistic set as the first t in the sequence. The second t doesn’t matter, so I’ve just made a glyph class called “t” containing all four t’s. This glyph class stands in for the arbitrary second t.

feature liga {
    # tt ligature
    sub t @t by t_t;
    sub t.ss01 @t by t_t.ss01;
    sub t.ss02 @t by t_t.ss02;
    sub t.ss03 @t by t_t.ss03;
} liga;

Discretionary Ligatures

The dlig feature contains ligatures activated using OpenType at the user’s discretion. Again, for Protest these are very limited—just IJ. This is primarily for Dutch users, but since it’s discretionary, I don’t need to use a language declaration.

Again, this is after the alternates, so I need to use classes as catchalls for the various forms of I and J. I also want to include an IJ acute ligature as well, for which I’ll use classes containing all I acute and J acute glyphs.

feature dlig {
    sub @I @J by IJ;
    sub @Iacute @Jacute by IJacute;
} dlig;

I only have one IJ right now, but if there is demand I may add more.

Up Next

In the next post, the epic saga of the contextual alternates!

  • Part 4: calt, aalt
  • Part 5: mark, mkmk
  • Kerning!
2018-11-22T23:20:54+00:00November 23rd, 2018|Categories: How, Type|Tags: , , , , , |

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.