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
1 Correct answer
Try
myCharacterStyle.position = Position.SUPERSCRIPT
See the following
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
Copy link to clipboard
Copied
Try
myCharacterStyle.position = Position.SUPERSCRIPT
See the following
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
Copy link to clipboard
Copied
Hi,
For Superscript you have to do this:
myCharacterStyle.position = Position.OT_SUPERSCRIPT;
Best
Sunil
Copy link to clipboard
Copied
Hello Sunil,
Could you please share how to do superscript text with any example
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
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.
Copy link to clipboard
Copied
thank you guys,
thank so much

