Copy link to clipboard
Copied
InDesign 18.5, Win 10.
The script (a snippet is given) should create a Paragraph Style that uses the Myriad Pro Bold SemiСondensed font.
The problem is that the script somehow cannot find the FontStyle named "Bold Semicondensed". But the specified font style is in the InDesign list and can be manually selected.
The script has no problems with other fonts (Minion Pro Italic), everything works with all their possible styles.
I tried using an instance of the Font object instead of the font family name, but I couldn't figure out how to specify the FontStyle for it. By default, it returns Regular.
Maybe an async call should be used (???), but there's very little information about that...
Here is the script "CreateParaStyle.idjs":
const {
app,
Justification,
SpanColumnTypeOptions
} = require('indesign');
let doc = app.documents.add();
doc.paragraphStyles.add({
name: "ps_DOI",
fontFamily: "Myriad Pro",
fontStyle: "Bold SemiCondensed",
pointSize: "12pt",
ligatures: true,
justification: Justification.LEFT_ALIGN,
minimumWordSpacing: 80,
desiredWordSpacing: 100,
maximumWordSpacing: 133,
spanColumnType: SpanColumnTypeOptions.SINGLE_COLUMN,
fillColor: "Black"
});
Option using Font (needs clarification):
const {
app,
Justification,
SpanColumnTypeOptions
} = require('indesign');
let doc = app.documents.add();
let fnt = app.fonts.itemByName("Myriad Pro");
// HOW TO REQUEST "Bold SemiCondensed" ???
doc.paragraphStyles.add({
name: "ps_DOI",
fontFamily: fnt, //"Myriad Pro",
fontStyle: "Bold SemiCondensed",
pointSize: "12pt",
ligatures: true,
justification: Justification.LEFT_ALIGN,
minimumWordSpacing: 80,
desiredWordSpacing: 100,
maximumWordSpacing: 133,
spanColumnType: SpanColumnTypeOptions.SINGLE_COLUMN,
fillColor: "Black"
});
Copy link to clipboard
Copied
Try the full name
Copy link to clipboard
Copied
Your script should work in respect to the DOM.
Try this, seems too work:
doc.paragraphStyles.add({
name: "ps_DOI",
appliedFont:"Myriad Pro Semibold Condensed",
pointSize: "12pt",
ligatures: true,
justification: Justification.LEFT_ALIGN,
minimumWordSpacing: 80,
desiredWordSpacing: 100,
maximumWordSpacing: 133,
spanColumnType: SpanColumnTypeOptions.SINGLE_COLUMN,
fillColor: "Black"
});
Copy link to clipboard
Copied
Thank you very much! Everything works fine!
Now I'm wondering if I should replace the use of the two properties "fontFamily" and "fontStyle" with only "appliedFont"...
Copy link to clipboard
Copied
Well if it works…
But fontStyle/fontFamily should have worked, probably some UXP weirdness.
Copy link to clipboard
Copied
try
let fnt = app.fonts.itemByName("Myriad Pro\tBold SemiCondensed");
that's a tab character between family and style.
Or assign that string directly to the appliedFont property.
If UXPScript works like in ExtendScript in this regard (can't test right now), the following snippet should give some more ideas with a paragraph style configured in the UI. You'll miss its sub-objects, though:
console.log(myPstyle.properties.toSource());