1

I have InDesign JavaScript code that replaces strings of specific fonts. Tt works (mostly) including for appliedFont values containing spaces and dashes e.g. Walkman-Chanakya-905, Devlys 180 Thin:-

app.findGrepPreferences.appliedFont = srcFont; 
app.findGrepPreferences.fontStyle = srcStyle; 
app.findGrepPreferences.findWhat = findWhat;
app.changeGrepPreferences.appliedFont = tgtFont;
app.changeGrepPreferences.fontStyle = tgtStyle;
app.changeGrepPreferences.changeTo = changeTo;

But it fails only when appliedFont is set to this - Walkman-Chanakya-905 (TT)

However when I set the same font (and style) in the find dialog under the grep tab it works as expected.

enter image description here

It also works when I disable font matching so it is likely it has something to do with the font (name).

// disabling this works -> app.findGrepPreferences.appliedFont = srcFont; 
app.findGrepPreferences.fontStyle = srcStyle; 
app.findGrepPreferences.findWhat = findWhat;
app.changeGrepPreferences.appliedFont = tgtFont;
app.changeGrepPreferences.fontStyle = tgtStyle;
app.changeGrepPreferences.changeTo = changeTo;

What is happening?

5
  • Does it work with other fonts with brackets () on the name?
    – Luciano
    Nov 27, 2019 at 12:03
  • Thanks. I have no other fonts with a name that has brackets. I don't even have this font available but that should be fine as I don't have many others either.
    – Himanshu
    Nov 27, 2019 at 12:11
  • 1
    when I use the "package" functionality on a file, I see a file created in the package folder with the "idml" extension. If you see this, it is a zip file, rename it to the "zip" extension, unzip it and look for a file called "fonts.xml" in one of the subfolders, check the indesign-internal name for the problem font to see if there is a naming discrepancy.
    – Yorik
    Nov 27, 2019 at 16:55
  • Yes let me check that and come back. Thanks.
    – Himanshu
    Dec 3, 2019 at 8:26
  • You can check all the fonts in a document using app.Document.fonts iterate over this and print font.fullName to get the font's internal name
    – One Face
    Apr 20, 2020 at 15:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.