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

how to define superScript?

Contributor ,
Jul 16, 2019 Jul 16, 2019

Copy link to clipboard

Copied

Hi experts,

how to make a superscript characterStyle?

my script like this:

var myDocument = app.activeDocument;

var myCharacterStyle = myDocument.characterStyles.item ("sup" );

      !myCharacterStyle.isValid && myCharacterStyle = myDocument.characterStyles.add({name:"sup"});

      myCharacterStyle.baselineShift = superScript;

but not working

could someone please show me how.

thanks

regard

John

TOPICS
Scripting

Views

1.7K

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

Community Expert , Jul 16, 2019 Jul 16, 2019

Try

myCharacterStyle.position = Position.SUPERSCRIPT

See the following

position

Position

Position.NORMAL

Position.OT_DENOMINATOR

Position.OT_NUMERATOR

Position.OT_SUBSCRIPT

Position.OT_SUPERSCRIPT

Position.SUBSCRIPT

Position.SUPERSCRIPT

NothingEnum.NOTHING

read/write

The text position relative to the baseline. Can return: Position enumerator or NothingEnum enumerator.

-Manan

Votes

Translate

Translate
Community Expert ,
Jul 16, 2019 Jul 16, 2019

Copy link to clipboard

Copied

Try

myCharacterStyle.position = Position.SUPERSCRIPT

See the following

position

Position

Position.NORMAL

Position.OT_DENOMINATOR

Position.OT_NUMERATOR

Position.OT_SUBSCRIPT

Position.OT_SUPERSCRIPT

Position.SUBSCRIPT

Position.SUPERSCRIPT

NothingEnum.NOTHING

read/write

The text position relative to the baseline. Can return: Position enumerator or NothingEnum enumerator.

-Manan

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
Advocate ,
Jul 16, 2019 Jul 16, 2019

Copy link to clipboard

Copied

Hi,

For Superscript you have to do this:

myCharacterStyle.position = Position.OT_SUPERSCRIPT;

Best

Sunil

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
New Here ,
Apr 29, 2020 Apr 29, 2020

Copy link to clipboard

Copied

Hello Sunil,

Could you please share how to do superscript text with any example

 

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
Advocate ,
May 01, 2020 May 01, 2020

Copy link to clipboard

Copied

LATEST

Hello ,

Lets just say there is a character which you want to make it super script.

Make a new Character style named "SuperScript" and apply to that character.

and run this code below :

///////////////////////////////////////////////////////////

app.documents[0].characterStyles.item("SuperScript").position = Position.OT_SUPERSCRIPT;

///////////////////////////////////////////////////////////

Or if you want without character style, just select that character and run this below code :

///////////////////////////////////////////////////////////

app.selection[0].position = Position.OT_SUPERSCRIPT;

///////////////////////////////////////////////////////////

Hope you found the result...

 

P.S. Reason behind putting Position.OT_SUPERSCRIPT is that this will work for Open type fonts. Otherwise you can use Position.SUPERSCRIPT as well.

 

Best

Sunil

 

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 16, 2019 Jul 16, 2019

Copy link to clipboard

Copied

1. Make sure you understand the right property to change. "baselineShift" is "The baseline shift applied to the text" (https://www.indesignjs.de/extendscriptAPI/indesign-latest/#CharacterStyle.html ), and you want to change superscript. Search the text on that page to find the correct property.

2. Make sure you understand JavaScript syntax. 'x = superScript' will yield an error, namely, the variable "superscript" is not defined.

3. Do not say "not working" without actually adding what does not work.

4. Search before asking. This older question looks very much like what you ask:  Re: Apply superscript position into character style

5. Do not say "not working" without actually adding what does not work.

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
Contributor ,
Jul 16, 2019 Jul 16, 2019

Copy link to clipboard

Copied

thank you guys,

thank so much

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