Contextual Alternates Question

oldnick's picture

I don't get out much, so pretty much everything I know about OpenType programming, I've learned here. Ergo...

I'm working on a font that requires contextual alternates for certain characters (A, H, I, M, N, T, X and any accented characters associated with same) preceding EVERY instance of S, X, Z, s, x and z. I'm not sure what the easiest way to accomplish this is, and how to avoid recursive problems with X.

Any suggestions would be greatly appreciated.

paul d hunt's picture

Make three classes, for example

@pre = [A H I M N T X]; # the glyphs you want to substitute out
@post = [A.alt H.alt I.alt M.alt N.alt T.alt X.alt]; # the glyphs you want to substitute in go here
@context = [S X Z s x z]; # the glyphs that trigger your substitution go here

Then in your Contextual Alternates (calt) feature use the following code

feature calt {
sub @pre' @context by @post;
} calt;

oldnick's picture

Thanks, Paul: that's an elegant solution, and it works like a charm.

paul d hunt's picture

you're quite welcome. This may not be all the code you need, but it provides the most basic functionality for what you were asking about.

Syndicate content Syndicate content