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

Super script with script?

Explorer ,
Feb 29, 2024 Feb 29, 2024

Copy link to clipboard

Copied

Untitled-4.pngexpand image

pun not intended, 

whilst docs do mention

FontOpenTypePositionOption.OPENTYPESUPERSCRIPT,

I could not get it working

TOPICS
Scripting

Views

336
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 , Feb 29, 2024 Feb 29, 2024

ok, found it by comparing 2 objects.
in case someone's struggling too, it's:
characterAttributes.baselinePosition = FontBaselineOption.SUPERSCRIPT

Votes

Translate
Adobe
Explorer ,
Feb 29, 2024 Feb 29, 2024

Copy link to clipboard

Copied

ok, found it by comparing 2 objects.
in case someone's struggling too, it's:
characterAttributes.baselinePosition = FontBaselineOption.SUPERSCRIPT

Votes

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
Advocate ,
Mar 01, 2024 Mar 01, 2024

Copy link to clipboard

Copied

Bonjour,

Pour s'amuser un peu...

 

Document ouvert, lancer le script.

// JavaScript document for Illustrator
// Landry René
// elleere Wed, 25 April 2018 17:39:04 GMT
// INIT---------
var c1 = "^";
var c2 = "_";
var text = "2^2.5 + b^2 = 5 C_12^2 sin(20^3)";   // cas 1
//var text = "2^2.5 + b^2 = 5 C^2_12 sin(20^3)"; // cas 2
var corps = 16;
//-------------
var docRef = activeDocument;
var pointText = docRef.textFrames.add();
    pointText.contents = text;
    pointText.position  = [20,-20];
    pointText.textRange.size = corps;
     //expo_indice(pointText,c1,1); // si cas 2
     expo_indice(pointText,c2,0);
     expo_indice(pointText,c1,1); // si cas 1
//--------------
function expo_indice(textRf,rx,drap) {
  var index, pos, i, r, curentChar, suit, baseline;
      baseline = drap ? FontBaselineOption.SUPERSCRIPT : FontBaselineOption.SUBSCRIPT;
      pos = index = textRf.contents.indexOf(rx);
      suit = textRf.contents;
        while (pos != -1) {
          suit = suit.substring(pos+1);
          r = parseFloat(suit)+"";
          //r = drap ? parseFloat(suit)+"" : "1";  // si toujours 1 chiffre
            for (i = 1; i <= r.length; i++) {
              curentChar = textRf.textRanges[index+i];
              curentChar.baselinePosition = baseline;
            }
          textRf.textRanges[index].remove();
          pos = suit.indexOf(rx);
          index += pos;
        }
}
//--------------

 

Votes

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
New Here ,
Oct 24, 2024 Oct 24, 2024

Copy link to clipboard

Copied

LATEST

hello, the baselinePosition property seems not working on my character, while using $.writeln() showed the change of it.

textFrame.textRange.characters[Index].characterAttributes.openTypePosition = FontOpenTypePositionOption.OPENTYPESUPERSCRIPT

 

Votes

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