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

how to define superScript?

Contributor ,
Jul 16, 2019 Jul 16, 2019

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
2.2K
Translate
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

Translate
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

Translate
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

Hi,

For Superscript you have to do this:

myCharacterStyle.position = Position.OT_SUPERSCRIPT;

Best

Sunil

Translate
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

Hello Sunil,

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

 

Translate
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
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

 

Translate
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

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.

Translate
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

thank you guys,

thank so much

Translate
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