Make pseudorandom calt cycling forwards instead of backwards

[SOLVED]

I created a pseudorandom calt cycling feature for a client using Create pseudorandom calt feature.py.

But my client is concerned about the way the substitution works where it actively switches letters as a string gets longer. I understand this is due to the code where it necessarily needs to start with the longest string. Is there another way to do it so it doesn’t switch the entire string the more you type?

The structure of the font is that the /o has 3 alternates (@calt00 is default o, @calt03, @calt04, @calt05 are the 3 other /o), and the code is like such (it starts off a lot longer but I’ve clipped to the end of the code):

sub @calt00' @All @All @All @All @All @All  by @calt03;
sub @calt00' @All @All @All @All @All  by @calt04;
sub @calt00' @All @All @All @All  by @calt00;
sub @calt00' @All @All @All  by @calt05;
sub @calt00' @All @All  by @calt04;
sub @calt00' @All  by @calt03;

If I reverse it obviously won’t work anymore. Even if I put each line in a separate lookup.

Edit: OK I figured it out :slight_smile: this works:

lookup o1 { sub @All @calt00'  by @calt03; } o1;
lookup o2 { sub @All @All @calt03' by @calt04; } o2;
lookup o3 { sub @All @All @All @calt04' by @calt05; } o3;
lookup o4 { sub @All @All @All @All @calt05' by @calt00; } o4;
lookup o5 { sub @All @All @All @All @All @calt00' by @calt04; } o5;
lookup o6 { sub @All @All @All @All @All @All @calt04' by @calt03; } o6;

The trick was to put each line into a separate lookup and then put the contextual glyph at the end of the contextual string and also the same as what the previous line substituted it into.