Skip to main content
Inspiring
July 16, 2019
Answered

how to define superScript?

  • July 16, 2019
  • 4 replies
  • 2453 views

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

This topic has been closed for replies.
Correct answer Manan Joshi

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

4 replies

JohnwhiteAuthor
Inspiring
July 16, 2019

thank you guys,

thank so much

Jongware
Community Expert
Community Expert
July 16, 2019

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.

Sunil Yadav
Legend
July 16, 2019

Hi,

For Superscript you have to do this:

myCharacterStyle.position = Position.OT_SUPERSCRIPT;

Best

Sunil

Participating Frequently
April 29, 2020

Hello Sunil,

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

 

Sunil Yadav
Legend
May 1, 2020

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

 

Manan JoshiCommunity ExpertCorrect answer
Community Expert
July 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

-Manan