Highlighted

how to define superScript?

Contributor ,
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

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

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

TOPICS
Scripting

Views

497

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

how to define superScript?

Contributor ,
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

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

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

TOPICS
Scripting

Views

498

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
Jul 16, 2019 0
Adobe Community Professional ,
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

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
Reply
Loading...
Jul 16, 2019 0
Adobe Community Professional ,
Jul 16, 2019

Copy link to clipboard

Copied

Hi,

For Superscript you have to do this:

myCharacterStyle.position = Position.OT_SUPERSCRIPT;

Best

Sunil

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
Reply
Loading...
Jul 16, 2019 2
New Here ,
Apr 29, 2020

Copy link to clipboard

Copied

Hello Sunil,

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

 

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
Reply
Loading...
Apr 29, 2020 0
Adobe Community Professional ,
May 01, 2020

Copy link to clipboard

Copied

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

 

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
Reply
Loading...
May 01, 2020 1
Most Valuable Participant ,
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.

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
Reply
Loading...
Jul 16, 2019 4
Contributor ,
Jul 16, 2019

Copy link to clipboard

Copied

thank you guys,

thank so much

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
Reply
Loading...
Jul 16, 2019 0