Conflicting calt rules

I have a question about the order of calt rules. I hope my commenting here has made this clear enough. Everything works perfectly all together EXCEPT for one rule (which I’ll explain below).

If I use ONLY that one rule, it works perfectly (meaning it’s not that specific rule that’s the problem).

So it seems I have a conflict here, but I would think that the order of my rules here would “fix” that conflict. Apparently I’m wrong about that.

Here’s what I’ve got, with comments to try to help make this really clear. I am finalizing a casual script font in which six of the letters do not connect to the letters after them (but the font includes connected version of all six letters as options, and I’m using calt to make it so that any problematic or ugly combinations are substituted with the connected versions).

// Always have a connected letter before z
sub [@basic-unconnected]’ [z zacute zcaron zdotaccent] by [@basic-connected];

//Always have a connected letter before r.calt
sub [@basic-unconnected]’ [r.calt racute.calt rcaron.calt rcommaaccent.calt] by [@basic-connected];

// Fix awkward W interactions
sub [W Wacute Wcircumflex Wdieresis Wgrave ]’ [ i idotless iacute icircumflex idieresis idotaccent igrave imacron iogonek l lacute lcaron lcommaaccent lslash t tbar tcaron tcedilla tcommaaccent ] by [W.calt Wacute.calt Wcircumflex.calt Wdieresis.calt Wgrave.calt ];

// After a space, never have a disconnected letter
sub space [@basic-unconnected]’ by [@basic-connected];

NOTE: Because @basic-connected includes r.calt, this rule can lead to having space/r.calt, which is bad and needs to be avoided - I have dealt with this with a separate rule below, but that’s the rule that is not being applied properly

// After a space, never have r.calt (instead, have r.init)
sub space [r.calt racute.calt rcaron.calt rcommaaccent.calt]’ by [r.init racute.init rcaron.init rcommaaccent.init];

// Never have two unconnected letters in a row (change the first one to connected)
sub [@basic-unconnected]’ [@basic-unconnected] by [@basic-connected];

Note: This rule can theoretically lead to having space/r.calt, which as I said above is bad, but it comes after the rule in which r.calt would already have been changed to r.init (r.init is not in @basic-unconnected, so it shouldn’t be affected by this rule)

//Never have r after r.calt (change the second to r.calt as well)
sub [r.calt racute.calt rcaron.calt rcommaaccent.calt] [r racute rcaron rcommaaccent]’ by [r.calt racute.calt rcaron.calt rcommaaccent.calt];

So when I have all of that and then type, for example, space-r-a what I want to have as the result is space-r.init-a but instead I am getting the result space-r.calt-a

When I test it with other stuff around to see if every single rule is working, the result is that every rule is applied EXCEPT for

// After a space, never have r.calt (instead, have r.init)
sub space [r.calt racute.calt rcaron.calt rcommaaccent.calt]’ by [r.init racute.init rcaron.init rcommaaccent.init];

Can anyone help me figure out how to fix this? Does the order of the rules not matter? And if it doesn’t, then what can I do here? I’m sure it must be possible!

I should add, despite this being a script, r.init is my only initial form. So I don’t have any other calt features that are, like, making all first-letters into .init versions.

This can better be taken care of with an ignore rule:

ignore sub @AllLetters @basic-unconnected', [r racute rcaron rcommaaccent]';
sub @basic-unconnected' by @basic-connected;

This substitutes unconnected for connected glyphs, but ignores all cases where the unconnected is preceded by any letter, and all cases where the unconnected is r or an r diacritic. Not sure how it is set up. From what I see, I guess it would probably have to be the .init variants of these r’s.

@mekkablue thank you for the help. I implemented your suggestion and it worked great for replacing the “sub space [@basic-unconnected]’ by [@basic-connected];” part, but I couldn’t quite understand what to do about the r.init part.

But then I figured it out and thought I’d share here in case anyone needs something like this in the future! I ended up doing this:

lookup GENERALAFTERSPACE {
ignore sub @AllLetters @basic-unconnected’, [r racute rcaron rcommaaccent]’;
sub @basic-unconnected’ by @basic-connected;
} GENERALAFTERSPACE;

this makes it so that no word starts with an unconnected letter, but it leaves any beginning unconnected r to be dealt with in the next lookup, which is as follows:

lookup RAFTERSPACE {
ignore sub @AllLetters @basic-unconnected’;
sub space [r racute rcaron rcommaaccent]’ by [r.init racute.init rcaron.init rcommaaccent.init];
} RAFTERSPACE;

I don’t know if this is the best-practice method or not, but it works! Now if only it also worked after a hard return, I’d really be all set. :slight_smile:

Oh wait! I just removed “space” from the second lookup and now it works after a hard return. WIN!

1 Like