Random Contextual Alternates Code

Hi everyone!

I made a font with 60 alternate glyphs for each character of the Latin alphabet and am now trying to set it up/code in Glyphs.
The goal is that each alternate appears randomly when I type:
If I type the word CAT it would be typed (for ex.) with the characters C.ss22+A.ss08+T.ss41 and If I type it again : C.ss59+A.ss35+T.ss18 etc. so super randomly

I have looked through the forum+the tutorials and I started to code the alternates using the calt function, but the only way for me to get let’s say C.ss22 is to have 21 Cs typed in before. Also the space bar resets the code, so I would probably never get anywhere further than C.ss02…

Is there a way to fix that? using the rand function? (which I understood isn’t supported by major apps?)

thank you!

Did you read this: Features, Part 3: Advanced Contextual Alternates | Glyphs

1 Like

Yes, I used the contextual cycling code from that tutorial!
But as I have so many alternates I don’t think using the multiple classes method would work… or would it?

Is there a way to make the classes more random? so that they are not always displayed/chosen in their original order (so not ALT1->ALT2->ALT3 but ALT53->ALT7->ALT46 for ex.) ?

  1. Use cvXX, not ssXX. Should be easy to replace: select all glyphs and press Cmd-Shift-F, find ‘.ssx’ and replace it with ‘.cv’.

  2. There is no true randomization possible with fonts. Yes there is a rand feature but it is hardly supported anywhere. The code would be something like:

sub A from [A.cv01 A.cv02 A.cv03];

And so on. There is a script in the mekkablue scripts for building the rand feature.

However you will need to double up with pseudorandomisation in calt and your best shot is the method described in the tutorial. Writing the exact same line twice will give you the same alternates, but just a letter difference will create something very different already.