Typophile

Simple Contextual Substitutions

Robby Woodard

I am setting up a font that I hope will look somewhat hand written when set. I have a stylistic alternate for every glyph with just slight changes in hand variance and attitude.

I would like to set up an OT feature where whenever two of the same glyphs are repeated side by side, the second glyph switches to the alternate.

I have page 868 of the FontLab manual open. But it is not making a lot of sense to me right now.

First, what would I call this feature in the OT window?

Would the code look something like this?:

Sub e e’ by e.alt;

And then set that up for every glyph. Or am I confused?

And then, how would that feature be turned on and off in the app?

I have it set up to where I can switch out the alternates by hand, but other users will be lazier than me and I would love to see some kind of automatic feature.

As long as my head doesn’t explode trying to code it…

Yes that's it, You have it right.

There is also a alternate way of doing it with very large sets of substitutions and that is with classes.

Basically you just drag and drop all the sets into classes and as long as they are in the correct order and size the code would be as follows:

feature calt { # Or whatever feature you choose.
sub @letter @letter2' by @letter3 ;

} calt;

So you would make open type classes and drag all the first letters into one called
letter into it and make a new open type class called letter2 and drag all the second letters into it and then make a third class called letter3 and drag in all the replacement glyphs into that.

Now that is not exactly correct but I'm pretty sure Fontlab will change and compile it correctly when you make the font. It will run in the open type preview correctly inside Fontlab as written just fine for debugging.

If you do it your way I'm pretty sure Fontlab will make it sort of like my way on compiling the font. It will try to add them all to classes to make the code much smaller. You just have to make sure they are all in the correct order and that all three classes have the same exact amount of glyphs. It will not compile and give you a warning if that is not the case.

I just finished a font like this. I used three of every glyph in the font (including punctuation, spaces, nonbreaking spaces, and soft hyphens) in three classes; default, alt1, and alt2. My code (based on older code by Tom Phinney and others) is:

feature calt {
lookup rotate {
sub @default @default' by @alt1;
sub @alt1 @default' by @alt2;
} rotate;
lookup rotate;
} calt;

To make it work in Indesign one has to use CALT (contextual alternates), because Indesign does not support SALT (complain about that here).

You also need to set up kerning classes to control interaction between the different character sets (unless all of the characters vary enough to require manual kerning of everything). I recommend that you set up all of the classes in a text editor, proof them, and then import them. Otherwise you’ll have to find your mistakes by looking at the errors the Opentype compiler generates, which can be a PITA because errors fonts with large classes can cause the compiler to mangle the classes.

I think this is working....

Thanks, guys!

Captured from web.archive.org on 8 Nov 2013. view this capture