What Features Do
Features can do two things: substitute glyphs and move glyphs. In this installment, we’ll focus on substitution. Please note that I said glyphs, not characters. Features cannot change the text entered by the user (i.e. the characters), only how it is displayed (i.e. the glyphs you drew in your font).
Enough blabla, let’s go ahead and create a feature for our font. Go into your font’s Font Info (Cmd-I) and switch to the Features tab. It should look like this:
On the left, you get an overview of prefixes, features and classes. On the right, you get two text fields, the top text field is for your feature code, the bottom text field is for notes or saving chunks of code you temporarily deactivate and perhaps want to re-use later. Above the top text field you find two checkboxes, one to automatically generate features, the other one to disable the feature.
So, all we need now is a feature. Click on the plus button at the bottom left. A miniature submenu appears, and we pick Feature. Now, the window should look like this:
Congratulations! You have just created a feature called
xxxx. Yay! Now you can code a feature in the upper text field. Of course,
xxxx is not really such a good name for a feature. Layout software like InDesign or XPress, or even word processors like TextEdit expect that you stick to a naming convention for your 4-letter feature tag. To keep things simple, the feature tag should tell the user something about what the feature does. (The nice people at Microsoft keep a list of feature tag names, along with recommendations on how to use them. My advice: keep this hyperlink under your pillow and in your most favorite bookmarks. You will look at it often, trust me.)
After you created the
xxxx feature, it is ready to be renamed. Let’s pick
liga to start with. This feature tag stands for ‘Standard Ligatures’. According to Microsoft and Adobe, the
liga feature ‘replaces a sequence of glyphs with a single glyph which is preferred for typographic purposes.’ Sounds good.
When you build a feature, you actually put together a set of rules. Rules define what gets substituted by what. Here is what such a rule looks like:
sub f f k by f_f_k;
Let’s go through that, bit by bit. First, we have the word
sub, which defines the kind of rule we are dealing with. As mentioned above, this can either be a substitution or a positioning rule. And
sub clearly denotes a substitution rule.
Secondly, since we have a substitution, we need the sequence of glyphs that are to be replaced. In this case, we have three glyphs:
f, followed by another
f, followed by
k. Please note that these are the actual glyph names, so ä would be spelled out as
adieresis, ñ as
If we didn’t put the keyword
by after the sequence, it wouldn’t be clear what is to be replaced by what. Imagine our codeline was
sub f f k f_f_k, then it might as well be that
f f was to be replaced by the sequence
by, we tell the font what comes instead. Remember the naming convention for ligatures: the names of the individual letters connected by underscores. In our case, we have the three letters f, f and k molded into one, so it’s called
And now, very super-important: each rule takes a semicolon at its end. Easy, actually, but this actually is the number one source of errors. So in case your features don’t work, chances are you forgot the semicolon.
Of course, you can put several rules after each other, like this:
sub f k by f_k; sub f h by f_h; sub f i by fi; sub f l by fl; sub f f k by f_f_k; sub f f h by f_f_h; sub f f i by f_f_i; sub f f l by f_f_l;
Remark: You might have noticed that the names fi and fl don’t adhere to the naming convention. That’s because those two glyph names existed before the naming convention was there, and now it’s too late to fix it. Historically grown, never mind. Also, you can write all rules into a single line, if you prefer to do so. As long as you don’t forget about the semicolons, everything will work out fine.
Want to see if you did everything right? Hit the Compile button at the bottom of the window, and Glyphs will make your code available in the Edit tabs. There, you can test your feature by choosing it from the Features pop-up menu at the bottom left and start typing.
Of course, you should only put these rules into your font if you actually have those glyphs in your font. Because if you don’t, Glyphs will complain loudly but rightfully:
Automatic Generation of Features
And now, to your great disappointment, I have to admit that we did all this for nothing. Why? Because, if you stick to the above naming convention, Glyphs can create ligature features automatically. You can trigger automatic generation with the circled arrow button.
It will throw most ligature rules into
dlig (discretionary ligatures), but you can force them into
liga if you add a
.liga suffix to the names of the ligature glyphs, e.g.
f_f_h.liga. But Glyphs can automate more than just
dlig. You’ll find a list of recognized glyph names and name suffixes in the appendix of the Glyphs Handbook.
But at least, we now understand substitution features and can tell if something is wrong. Plus, we’re well-prepared for the upcoming second installment about contextual substitutions! So, stay tuned…
Sounds like fun? Then head right on to the next installment of the saga, Features, part 2: Contextual substitutions.
2015-07-02: Updated for Glyphs 2.
2018-07-24: Updated links and added links in Resources.
2019-03-28: Updated link for Adobe's specification.
2019-04-09: Updated link for the Glyphs manual.