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

Access Opentype Features by scripting

Explorer ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

 

sdsadasd.png

whilst UI displays contextual menu when selecting character, values in code
 
ligature:
false
discretionaryLigature:
false
contextualLigature:
false
fractions:
false
ordinals:
false
swash:
false
titling:
false
connectionForms:
false
stylisticAlternates:
false
ornaments:
false
 
does not to seem to do anything, sadly, in either 
 
tactiveDocument.textFrames[0].textRange.characters[0].characterAttributes
tactiveDocument.textFrames[0].textRange.characterAttributes
 
what I could be missing?

@m1b

maybe you have insights?

TOPICS
Scripting , SDK

Views

211

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

correct answers 1 Correct answer

Explorer , Jul 12, 2023 Jul 12, 2023

I found a solution for this particular case.

you have to set both 

.characterAttributes.connectionForms = true;
and
.characterAttributes.contextualLigature = true;
for ligature to appear, strangelly when set from context mini menu in illustrator UI
these value do not seem to change in code. 
 

Votes

Translate

Translate
Adobe
Explorer ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

I found a solution for this particular case.

you have to set both 

.characterAttributes.connectionForms = true;
and
.characterAttributes.contextualLigature = true;
for ligature to appear, strangelly when set from context mini menu in illustrator UI
these value do not seem to change in code. 
 

Votes

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 ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

My (limited) understanding is that the two alternative glyphs shown in your screen shot are derived directly from the font's opentype features, so that by turning the various available opentype features (ie. the ones that you mentioned in your post) on or off you will be able to find one or the other. For example:

item.textRange.characterAttributes.stylisticAlternates = true;

 

If that doesn't work for some reason, another avenue to try is to get the charCode of the character and see if that's significant. Usually it won't be because you are interested in the glyph which is mapped to the character, not the character itself, for example, my guess is that both "g" glyphs in your screen shot will have charCode 103. Anyway, you can test this:

$.writeln(item.textRange.contents.charCodeAt(0));

 This will show you the charCode of the first character of the text.

 

Can you try the various opentype features first and see if any work? If you get stuck you might need to share the sample document and font (if appropriate).

- Mark

Votes

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
Explorer ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

thanks for your reply, Mark

 

at the end I had managed to get swoosh to show by setting both connectionForms and contextualLigature

to true. Strange still, settings from the UI context menu does not seem to change these values in js, I tried to trace them out to "false", so much poking and experimenting was involved.

 

There is no document involved, just a weird font https://allbestfonts.com/carolina/

 

 

Votes

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 ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

LATEST

Hi @dolce5EC2, glad you got it working.

quote

thanks for your reply, Mark

 

at the end I had managed to get swoosh to show by setting both connectionForms and contextualLigature

to true.

There is nothing strange here. It is exactly what I suggested.

 

Strange still, settings from the UI context menu does not seem to change these values in js, I tried to trace them out to "false", so much poking and experimenting was involved.

This might be because those properties will return false if your text contains multiple values. To properly test, you need to target, say, an individual character of the text, not the whole text. Just an idea. In my testing it worked as I expected.

- Mark

Votes

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