First I should mention that the goal here is not in fact randomness, because we want a "natural" effect, where adjacent glyphs are not identical--which is what would occur occasionally with a truly random disposition of glyphs.
In these examples, there are four alternates of each character in the font (including punctuation and, importantly, the space). They are sorted in four classes, @one, @two, @three and @four.
Version 1.0 was provided by Thomas Phinney. This is the first lookup.
It sets glyphs from a sequence of classes: 1234 1234 1234, which then repeats.
Version 2.0 is a tweak I provided, to deal with repetitive five-character sequences, as in "they do the things..."
This is implemented by the second lookup.
It sets the class sequence to: 1234 1324 3142, which then repeats.
Version 3.0 deals with the line-break problem. (Because layout applications don't carry contextuality from one line to the next, starting over every line, a word like "the" at the start of a line is set with the same glyphs every time.) This method was suggested by John Hudson. It works backwards from the fifth character in the line (chosen, again, to deal primarily with the problem of "the"). My code splits possible fifth letters into seven groups, arranged to separate those that occur most frequently in English into different groups. The seventh group is the default, and not coded. It includes all accented characters, as I have not bothered to make truly comprehensive classes, as I did with classes one through four, which might include them.
This adjusts Version 2.0 by changing the first four classes in the sequence, depending on the fifth character in the line, to one of: 3143, 4324, 2413, 3214, 4132, 2314 or 1432.
feature calt {
lookup calt_one {
sub @one @one' @one by @two;
sub @two @one' @one by @three;
sub @three @one' @one by @four;
} calt_one;
lookup calt_two {
sub @four @one @two' by @three;
sub @three @three' by @two;
sub @two @four @one' by @three;
sub @four @three @two' by @one;
sub @three @one @three' by @four;
sub @four @four' by @two;
} calt_two;
lookup calt_three {
sub @one' @two @three @four [E M V e m v one space] by @three;
sub @two' @three @four [E M V e m v one space] @three by @one;
sub @three' @four [E M V e m v one space] @three @two by @four;
sub @four' [E M V e m v one space] @three @two @four by @two;
} calt_three;
lookup calt_four {
sub @one' @two @three @four [T U B t u b two space.alt2] by @four;
sub @two' @three @four [T U B t u b two space.alt2] @three by @three;
sub @three' @four [T U B t u b two space.alt2] @three @two by @two;
sub @four' [T U B t u b two space.alt2] @three @two @four by @four;
} calt_four;
lookup calt_five {
sub @one' @two @three @four [P A C p a c three nine space.alt3] by @two;
sub @two' @three @four [P A C p a c three nine space.alt3] @three by @four;
sub @three' @four [P A C p a c three nine space.alt3] @three @two by @one;
sub @four' [P A C p a c three nine space.alt3] @three @two @four by @three;
} calt_five;
lookup calt_six {
sub @one' @two @three @four [L I Q Y l i q y four eight] by @three;
sub @two' @three @four [L I Q Y l i q y four eight] @three by @two;
sub @three' @four [L I Q Y l i q y four eight] @three @two by @one;
sub @four' [L I Q Y l i q y four eight] @three @two @four by @four;
} calt_six;
lookup calt_seven {
sub @one' @two @three @four [D O G Z d o g z five] by @four;
sub @two' @three @four [D O G Z d o g z five] @three by @one;
sub @three' @four [D O G Z d o g z five] @three @two by @three;
sub @four' [D O G Z d o g z five] @three @two @four by @two;
} calt_seven;
lookup calt_eight {
sub @one' @two @three @four [F R J N f r j n six seven] by @one;
sub @two' @three @four [F R J N f r j n six seven] @three by @four;
sub @three' @four [F R J N f r j n six seven] @three @two by @three;
sub @four' [F R J N f r j n six seven] @three @two @four by @two;
} calt_eight;
sub @two @two' by @one;
sub @one @one' by @two;
} calt;
I suspect it may be possible to configure a system that works entirely with backwards-activation, but it is too mind-boggling for me to figure out.
[Sorry, I meant to post this in the Build forum.]
