Changing to alternate glyph via javascript

Community Beginner ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

What I want to do:

Change a specific character to it's alternate glyph.

What I have been trying:

var myDoc = app.activeDocument;

//get the text frame
var tf = myDoc.textFrames[0];
//change the size of a specific character
tf.textRange.characters[0].characterAttributes.size = 36;
//try and change the specific character to it's alternate style
tf.textRange.characters[0].characterAttributes.stylisticAlternates = true;

Where I am currently:

-I can access a specific character and tested that by changing it's size which works.

-I am unable to change that character to it's alternate glyph. 

-I have also tried messing aroound with "AlternateGlyphsForm" to no avail.

 

Question:

Does anyone know how to change a text item to it's alternate font glyph via javascript?

 

Thank you

TOPICS
How to, Scripting

Views

159

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
Adobe Community Professional ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

What kind of Alternate glyph are you working with? can you show samples?

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 Beginner ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

CARLOS.png

 

Hi CarlosCanto thank you for your reply.

 

Please excuse me if I am misusing terms, but I am essentially trying to swap the "L" here for it's alternate but I need to do so programatically.

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
Adobe Community Professional ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

I don't think there is a command to swap the alternates. I understand you just posted a random sample but on your real project, check the Open Type Panel for changes. If one of the circled icons highlights when you swap the available glyphs by hand, it might be possible to change it with javascript.

 

In the example below, if the alternate glyph is an Ordinal, the "1st" icon will highlight.

in javascript it will be the same as

selection.characterAttributes.ordinals = true;

 alternateGlyphs.JPG

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 Beginner ,
Jun 10, 2021 Jun 10, 2021

Copy link to clipboard

Copied

LATEST

All of the options in my Open Type panel are grey'd out sadly.

I've sort of run out of options at this stage for new things to try so perhaps just have to abandon this idea.

Thank you for your help anyway.

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