Contextual Alternates Conundrum

I’m currently trying to make a “smart” version of my experimental calligraphic font Maestrale, and I’m running into a problem with the calt feature. I’m sure there is a simple solution, but I haven’t found it yet.

This is what I’m trying to do. The lowercase letters {b h k l thorn longs} each come in three versions: A default one with a very tall, forward-curved ascender (let’s call that class @1), one with a slighly shorter ascender (@2), and one with an even shorter one (@3). Since having several such letters with identical ascenders looks mechanical and sterile, I’d like Glyphs to make the following substitutions:

@1 @1 ==> @2 @1
@1 @1 @1 ==> @2 @1 @3

For this, I naively wrote in the calt feature:

sub @1@1 by @2;
sub @2 @1 @1’ by @3;

Unfortunately, typing three such letters one after the other gives me @2 @2 @1 rather than @2 @1 @3. It seems the two-letter rule overrules the three-letter rule, regardless of how I reformulate and reorder the rules in the calt window (at least as far as I’ve tried…).

Is there a trick to making it behave as intended?

Cheers

Here’s what I’m trying to achieve… I made this with the “dumb”, do-it-yourself version of Maestrale.

Example

I think you need to put the second line in another lookup.

sub @1@1 by @2;
lookup three {
sub @2 @1 @1’ by @3;
} three;

(I wrote that in Safari so I might missed something)

The code you provided didn’t work because the first line turns 111 into 221 rather than 211. I got it to work like this, though:

lookup three {
sub @1 @1 @1’ by @3;
} three

lookup two {
sub @1@1 by @2;
} two

Thanks! I hadn’t known about this lookup syntax.

Is there a complete documentation of this programming languages somewhere?

For instance, is there a general wildcard symbol? Maestrale’s {f} is so exuberant that I’d like to be able to shorten letters that follow up to two slots after the {f}, as in “sub f * @Ascender by @ShortAscender;”.

Oh, I’m getting a weird error with dlig in the same font.

I have a number of ligatures marked with .dlig, such as o_o.dlig. However, automatically generating the feature table does not give me a dlig feature. If I add it in by hand and then click “generate feature automatically”, it deletes itself! What’s happening…?

You do not need the dlig suffix.

D’oh, thanks! :slight_smile:

No general wildcard, you have to put them all in a class and write out the classes.

Here’s the specification of the feature file syntax:
http://www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.html