Beginner Opentype Tip

May 23, 2013

Opentype font features give some pretty wonderful options for a more dynamic typeface. I did run into a couple of small problems setting up contextual substitutes for a script font. The o, v, and w in particular created the need for a special alternative character to keep the script connected correctly.

What I should have done was to hit the documentation from Adobe straight away rather than dig around font blogs first. I discovered I was getting errors in my handling of getting the feature to work even though the examples were/are technically correct, but for a different situation.

In my case I needed:

feature salt{
    sub[o v w] r' by r.salt;
} salt;

This takes any combination of or vr wr and replaces the r with it's stylistic alternative. The downside is that those three characters also have alt options for o v and w. So that doesn't work either, but classes come to the rescue:

@Os = [o o.salt o.init];
*Repeat for any others.*

Which turns the feature into:

feature salt{
    sub[@Os @Vs @Ws] r' by r.salt;
} salt;

This is simple enough. The only thing that seems odd is the single quote after the first r. I hadn't encountered it in other examples, but it pops up in the official documentation as 'marking a glyph or glyph class for contextual substitution'. 1

These are small things, but weren't terribly obvious when I was just jumping through blogs and documentation to get the answer. Hopefully this is helpful for others who are just getting into scripting Opentype features.