'random' sub [calt feature]

Is there any way to randomise substitutions in a calt feature? I made this >

sub @default @default' by @ss01;
sub @ss01 @default' by @SS01;
sub @SS01 @default' by @ss02;
sub @ss02 @default' by @SS02;
sub @SS02 @default' by @DEFAULT;

sub @NUM @NUM' by @NUMSS01;
sub @NUMSS01 @NUM' by @NUMSS02;

I bet there isn’t a random function for opentype scripting. Any ideas how can I approach it?

Thanks!

There is a rand feature, but it is not supported in any major app.

You can try and fake it with a complex calt feature. Try the pseudorandomizer in my GitHub repo, or have a look at the tutorials, especially this one:
https://www.glyphsapp.com/tutorials/features-part-3-advanced-contextual-alternates

1 Like

Thanks Mekka! Quick question, can I also implement the rand feature in the same ‘calt’ feature? I assume that this will work if it is supported by the app? and if not, it’ll trigger the lineal subs?

No, it is a different lookup type. In AFDKO code, you would write:

sub x from [x.1 x.2 x.3 x.4];

And how this is handled depends on the app and the feature.

1 Like

great!