• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Looking for a way to randomize font alternates

Community Expert ,
Dec 21, 2022 Dec 21, 2022

Copy link to clipboard

Copied

I created an OTF font using the Fontself plugin, which is a handwriting font for a graphic novel.

Uppercase and Lowercase (done in the Illustrator version of Fonself).

There are 4 alternates for each glyph. Would like the font to cycle through the alternates as I type. 

I have found articles on contextual coding but I was wondering if anyone knows what I can use, script perhaps with this allready created font.

Amybeth M
ACI G7 Certified Expert
TOPICS
How to , Scripting , Third party plugins , Tools

Views

126

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 21, 2022 Dec 21, 2022

Copy link to clipboard

Copied

You probably could use good old string.fromCharCode() in a script and randomize the character code in the parentheses. This wouldn't be interactive, of course, but could work. You just need to come up with a set of rules when to use what.

 

Mylenium 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 22, 2022 Dec 22, 2022

Copy link to clipboard

Copied

LATEST

To clarify, alternates use different Unicode codepoints to the canonical characters, typically somewhere in the U+E000–U+F8FF private use range. To insert alternate characters in AI using JSX, you need to know their codepoints.

 

e.g. OP might build a lookup table that maps the canonical A–Z, a–z, etc characters to their alternates. For each character in the original text, look up its alternate characters, pick one at random, and substitute:

 

var characterMap = {
  'A': 'A\ue001\ue002\ue003',
  'B': 'B\ue004\ue005\ue006',
  'C': ...
};

var oldText = someTextFrame.contents;

var newText = '';
for (var i = 0; i < oldText.length; i++) {
  var c = oldText[i];
  var alternates = characterMap[c];
  if (alternates) {
    c = alternates[Math.floor(Math.random() * alternates.length)];
  }
  newText += c;
}
someTextFrame.contents = newText;

 

 

FontForge is ugly but free and should suffice for examining the generated font’s glyph table to determine the alternates’ code points.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2022 Dec 21, 2022

Copy link to clipboard

Copied

Looks like it's possible to access this in InDesign: https://github.com/samiartur/Character-Variant-Java-Script-for-Indesign

 

This might or might not help with scripting Illustrator.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2022 Dec 21, 2022

Copy link to clipboard

Copied

Unfortunately the author is using the font in Photoshop but I am going to look into that  thank you 

Amybeth M
ACI G7 Certified Expert

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2022 Dec 21, 2022

Copy link to clipboard

Copied

I still cant figure out what to change on the script?

Amybeth M
ACI G7 Certified Expert

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2022 Dec 21, 2022

Copy link to clipboard

Copied

Hi @Amybeth M. ACI G7, I think the most robust way to achieve what you want is to use some clever OpenType Substitution Rules in your font. Basically the idea is that, while still deterministic, the rules can be sufficiently complex (and clever) to mix glyph alternates apparently randomly. Here is an interesting article that talks about the thinking involved in make a font randomised. It unfortunately doesn't show any example rulesets, which would have been cool. In the simplest case, you can replace glyphs E E' with E E.001 so that when the user types "BEER" the 2nd E doesn't match the first.

I'm not familiar with Fontself, and I'm not sure it gives much control over OpenType Substitution, so you may have to look for another tool if you decide to go this way.

- Mark

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 22, 2022 Dec 22, 2022

Copy link to clipboard

Copied

Thank you all for the information. Where Fontself is easy to use and an "in application"plug-in. (and works very well), it dosen't have alot of the options to code each glyph, as you create the font like some of the more expensive font creation software. Something to look into. I am going to play with the Indesign script. THX

Amybeth M
ACI G7 Certified Expert

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines