Hey, I just compiled a list of all the JavaScript commands to apply/remove OpenType features in InDesign through scripting. They should work in both CS2 & CS3, except the ones marked as ’CS3 only’.
myObject can be anything that accepts the properties, from a whole Story to a single Character. So, if you want to apply the properties to the first story in the document, you’ll need to declare ’myObject’ as:
var myObject = app.documents[0].stories[0];
If you only want to change the first line of text in a document, ’myObject’ should be declared like:
var myObject = app.documents[0].stories[0].lines[0];
And if what you want to change is the first character in a document, ’myObject’ should be:
var myObject = app.documents[0].stories[0].characters[0];
The properties can also be applied to paragraphs, text frames, words, etc.
Happy coding!!
################
// All Caps (case+cpsp)
myObject.capitalization = Capitalization.ALL_CAPS;
// Small Caps (smcp)
myObject.capitalization = Capitalization.SMALL_CAPS;
// All Small Caps (c2sc+smcp)
myObject.capitalization = Capitalization.CAP_TO_SMALL_CAP;
// to reset capitalization
myObject.capitalization = Capitalization.NORMAL;
// Ligatures (liga)
myObject.ligatures = false; // to turn off
myObject.ligatures = true; // to turn on
###
// Discretionary Ligatures (dlig+hlig)
myObject.otfDiscretionaryLigature = true;
// Fractions (frac)
myObject.otfFraction = true;
// Ordinal (ordn)
myObject.otfOrdinal = true;
// Swash (swsh+cswh)
myObject.otfSwash = true;
// Titling Alternates (titl)
myObject.otfTitling = true;
// Contextual Alternates (calt+clig)
myObject.otfContextualAlternate = true;
// Slashed Zero (zero)
myObject.otfSlashedZero = true;
// Stylistic Sets (ssXX)
myObject.otfStylisticSets = 8; // to apply Set 3 (ss03)
/*
0 = None
2 = ss01
4 = ss02
6 = ss01+ss02
8 = ss03
10 = ss01+03
12 = ss02+03
14 = ss01+02+03
16 = ss04
32 = ss05
64 = ss06
128 = ss07
...
OR
1 = None
3 = ss01
5 = ss02
7 = ss01+02
9 = ss03
11 = ss01+03
13 = ss02+03
15 = ss01+02+03
17 = ss04
19 = ss01+04
21 = ss02+04
...
*/
// Positional Forms (init, medi, fina, isol) -- CS3 only
//// General Form
myObject.positionalForm = PositionalForms.NONE;
//// Automatic Form
myObject.positionalForm = PositionalForms.CALCULATE;
//// Initial Form
myObject.positionalForm = PositionalForms.INITIAL;
//// Medial Form
myObject.positionalForm = PositionalForms.MEDIAL;
//// Final Form
myObject.positionalForm = PositionalForms.FINAL;
//// Isolated Form
myObject.positionalForm = PositionalForms.ISOLATED;
###
// Superscript/Superior (sups)
myObject.position = Position.OT_SUPERSCRIPT;
// Subscript/Inferior (subs if present, else sinf)
myObject.position = Position.OT_SUBSCRIPT;
// Numerator (numr)
myObject.position = Position.OT_NUMERATOR;
// Denominator (dnom)
myObject.position = Position.OT_DENOMINATOR;
// to reset position
myObject.position = Position.NORMAL;
###
// Tabular Lining (tnum+lnum)
myObject.otfFigureStyle = OTFFigureStyle.TABULAR_LINING;
// Proportional Oldstyle (pnum+onum)
myObject.otfFigureStyle = OTFFigureStyle.PROPORTIONAL_OLDSTYLE;
// Proportional Lining (pnum+lnum)
myObject.otfFigureStyle = OTFFigureStyle.PROPORTIONAL_LINING;
// Tabular Oldstyle (tnum+onum)
myObject.otfFigureStyle = OTFFigureStyle.TABULAR_OLDSTYLE;
// Default Figure Style
myObject.otfFigureStyle = OTFFigureStyle.DEFAULT_VALUE;
### Not available through the UI
// Historical Forms (hist)
myObject.otfHistorical = true;
// Localized Forms (locl) -- CS3 only
myObject.otfLocale = true;
// Mark Positioning, Required Ligatures,
// Glyph Composition / Decomposition
// (mark, mkmk, mset, rlig, ccmp) -- CS3 only
myObject.otfMark = true;
// Access any feature available in the font
// and specify the index of the alternate glyph
myObject.opentypeFeatures = [["salt", 0]]; // default glyph
myObject.opentypeFeatures = [["salt", 1]]; // 1st alternate glyph