I have a few files using font's that I like to replace with a different one, but fail to figure out how to do this with scripting. it's probably something very simple but I can't find it back anywhere...
for instance indd file containing character styles using [MyOldFont] as font family - > how do I itterate through all objects using some reference to this old font, and replace this to [MyNewFont] as font family with script ?
In character styles you say:
if (myCharacterStyle.appliedFont == "Font X")
myCharacterStyle.appliedFont = "Font Y")
and do that for all character styles and probably for paragraph styles as well. Then maybe do a find/change on the document to catch local applications of that font:
app.findGrepPreferences = app.changeGrepPreferences = null
app.findGrepPreferences.appliedFont = "Font X"
app.changeGrepPreferences.appliedFont = "Font Y"
I'm fairly new to this, but I think you may need to change the fontStyle as well as the appliedFont?
myCharacterStyle.appliedFont = "Font Y"
myCharacterStyle.fontStyle = "Bold"
True to some extend. In my specific case I wanted to chage the font but keep the style as it was defined for the original font.