I am working on a script font where several letters have 2 versions: one swashed (main) and one plain (alternate). When the same letter comes twice in a row I want to switch one of them around - to avoid colliding swashes.
I mainly use the calt feature like this: sub l l' by l.calt;
This works as expected, and if I keep repeating the letter the two versions alternate all the way.
But sometimes I want to switch the first letter: sub g' g by g.calt;
When I now keep repeating the letter I just get a long row of the switched glyph with the original glyph at the end - no continous alternation. How do I write the code to avoid this?
For simple letter pairs this is just a minor niggle (I really don't expect text to be set with many identical letters in a row), but as I want to group/class similar letters to also avoid collisions between different letters, I need to get this sorted.
I would really appreciate some input from someone with a better grasp on OpenType feature programming than myself ;)