For a specific project I've made an edit to the randomize function on the FontRyhthm script so that instead of randomly selecting from all installed fonts (using 'app.fonts') it randomly selects from a predetermined array (in my case, '['Times', 'Helvetica', 'Verdana']'. In its final iteration it will be 50+ specifically selected fonts).
This is all working well, however I now need to make the next step. I'd like it so that it randomly selects from the array of fonts, without selecting the same font twice until it has cycled through the entire array. A bit of googling and I found out that this process is better known as the Fisher-Yates shuffle
I also found this snippet of Fisher-Yates in js.
The edited line in the script currently looks like:
if(values.randomfont){
var array_randomfonts = ['Times', 'Helvetica', 'Verdana'];
var randomFont = array_randomfonts[Math.floor(Math.random()*array_randomfonts.length)];
charRange.characterStyle.font = randomFont;
} else {
charRange.characterStyle.font = fontchoice;
}
Any help or advice on how to apply Fisher-Yates shuffle to this would be great! If more details would be helpful please let me know.