A way to make 1 glyph per word switch to a second Stylistic Set at random?

Hey dear Forum, after contacting a few colleagues about this issue and receiving mostly shrugs, I hope I can find an answer here. My client wants their new headline typeface automatically sub a random, regular glyph in each word with a stylistic alternative. I don’t think this would work with initial, middle and end forms like with Arabic typefaces, nor with a custom calt-Feature (haven’t tried though, I really suck at programming). I have told the client that I can’t really guarantee this requirement to be solvable, but I have budgeted in a couple of extra hourly rates that I would be happy to pass over to someone who helps me solve this. Thank you, Max

1 Like

Two problems: in OpenType, there’s no random and there are no words.
You can fake it by putting random glyphs in a bunch of groups and then writing random combinations of different length. Make sure to include separators before or after to avoid multiple subs within one word. The same word will always appear the same though.

Feel free to put this into calt and take it from there:

@group1 = [g s a q];
@group2 = [p t w x c j];

@default = [a b c];
@alt = [A B C];

@separator = [space comma period];

sub @group1 @group1 @default' @group2 @separator by @alt;
sub @group2 @group1 @default' @group1 @separator by @alt;

sub @separator @group1 @group1 @default' @group2 by @alt;
sub @separator @group2 @group1 @default' @group1 by @alt;
1 Like

Couldn’t one use the rand feature?

Doesn’t seem to be terribly random:



Complete randomness is not possible. The resulting glyph order needs to be deterministic, otherwise the user would have problems with simple things like duplicating a line of text or even just moving it or zooming in, actually. There was a very good talk about this (and other OT problems) by Behdad Esfahbod at the Typo Labs conference a few years ago, but I couldn’t find the recording on YouTube now.

Thanks a lot Alexs, I’m not quite sure I can follow. I guess I could create groups made of actual words and make a reaaaaally long list of likely used words this way that would each have their own positional assignment of an ssXX glyph. At the risk of sounding like the idiot I am when it comes to all things code: why do you suggest creating groups of random glyphs? What effect does that have? And where do I »take it from there«?

There’s no need for making lists of actual words. By putting random glyphs in random groups, you can expect that words will be made of either letters belonging to those groups. Of course, you may need to do some testing to make it functional for as many words as possible.
Here’s a more simplified example:

@group1 = [c t d]; 
@group2 = [k p];
@group3 = [e];

@default = [a y o];
@alt = [A Y O];

sub @group1 @default' @group2 @group3 by @alt;

In this example you get all of these alternatives for 4 letter words made of the letters in those groups, in the order defined in the sub line:

cake > cAke
type > tYpe
dope > dOpe
cope > cOpe

If you’re not sure about the syntax, http://opentypecookbook.com is a good resource.