Can you show an example for a font where this is not working?
It's name you get, how you apply it.
And some code of course…
Isn't this the long-time problem where a script cannot get access to a 'document font' if the font is not available?
Of course. So, in example, this a working command:
app.findTextPreferences.appliedFont = "BentonSansCond\tRegular"; app.changeTextPreferences.appliedFont = "BentonSans Cond Regular\tRegular";
I have other fonts that won't replace. One shows up, missing in the document, as Benton Sans, Book, the other is Lexia Dama (TT), Bold. I tried any possible combination ("Lexia Dama (TT)\tBold", "Lexia Dama\tBold", "LexiaDama\tBold", etc.) and it just wouldn't replace it. So I wanted to find out whether I was using the wrong font name or InDesign was acting out and to do so I created a script that takes the font of the selected text and changes every instance of that font to a different font, to check whether InDesign correctly picks up the font name from a selection:
app.findTextPreferences.appliedFont = app.selection.appliedFont.name;
app.changeTextPreferences.appliedFont = "BentonSans Book\tRegular";
If I select a word and run the script, the correct font is recognised and every instance of that font is changed. Now following the same logic I tried to select a word using the missing font and then replacing every instance of that missing font with another font. Well, it doesn't work. I'm linking to a file containing an InDesign file with 2 text boxes and a script to test out. If I select the Benton Sans text, it gets replaced by a different font, if I select the other one nothing happens.
Just to be clear, this script DOES work with missing fonts with no problem, it's specific fonts I'm talking about. It throws no exception for missing fonts and works perfectly with them, just not all of them.