Copy link to clipboard
Copied
Hi,
I need to change a predefined paragraph style in 50 to 75 Indesign files. The paragraph style name is called “3. text”. Can someone help me wirte a simple javascript line to change the applied font name “Times New Roman” and fontstyle “Regular” to font name “YaleNew” and fontstyle “Roman”?
Thanks in advance for your assistance.
-Greg
1 Correct answer
Hi,
if a one liner is simply enough than this should do the trick
app.activeDocument.paragraphStyles.itemByName("3. text").appliedFont = "YaleNew\tRoman";
It will only change the font of the paragraph style 3. text in the currently active document.
Copy link to clipboard
Copied
Hi,
if a one liner is simply enough than this should do the trick
app.activeDocument.paragraphStyles.itemByName("3. text").appliedFont = "YaleNew\tRoman";
It will only change the font of the paragraph style 3. text in the currently active document.
Copy link to clipboard
Copied
Thanks Crazy Panda for your response and YES it does exactly what I need!
Now to make this script complete, can you give me another javascript one liner that will change the capitalization to Open Type Small Caps for character style called "3b. text, cap" ?
I attempted the following with no success:
app.activeDocument.characterStyles.itemByName("3b. text, cap").appliedFont = "YaleNew\tRoman", Capitalization.CAP_TO_SMALL_CAP;
-Greg
Copy link to clipboard
Copied
For capitalization you need to set the capitalization property as follows
app.activeDocument.characterStyles.itemByName("3b. text, cap").capitalization = Capitalization.CAP_TO_SMALL_CAP
For a complete list of properties and methods for character styles you can check the following link
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#CharacterStyle.html
-Manan
Copy link to clipboard
Copied
if you want to change both the font and the capitalization with one line:
app.activeDocument.characterStyles.itemByName("3b. text, cap").properties = {appliedFont: "YaleNew\tRoman", capitalization: Capitalization.CAP_TO_SMALL_CAP};
Copy link to clipboard
Copied
Exactly what I needed, thanks! I also appreciate the "CharacterStyle ExtendScriptAPL" link, however, I'm having difficult with some of the syntax.
For example, I tried to include OpenTypeFigureStyle.PROPORTIONAL_OLDSTYLE as follows:
app.activeDocument.paragraphStyles.itemByName("3. text").appliedFont= "YaleNew\tRoman", .otfFigureStyle.PROPORTIONAL_OLDSTYLE;
But this does not work. Can you help explain what I'm doing incorrectly?
-Greg
Copy link to clipboard
Copied
Ok, all resoloved after much trial and error. 😞
I was able to get the "PROPORTIONAL_OLDSTYLE" syntax to work using the following code:
app.activeDocument.paragraphStyles.itemByName("3. text").properties = {appliedFont: "YaleNew\tRoman", otfFigureStyle: OTFFigureStyle.PROPORTIONAL_OLDSTYLE};
Thanks again for all the assistance. 😉
-Greg

