Copy link to clipboard
Copied
Hey everyone,
So I have a group of indd's that I've booked, but each doc uses three fonts that I'd like to swap out for a different 3. Is there a script out there to find and replace these three fonts for all the docs in the book at once?
Thanks in advance!
-Andy
Copy link to clipboard
Copied
Hi Andy,
I hope below coding is your requirement,
if(app.books.length==0)
{
alert("please open the book")
exit(0);
}
var myBook = app.activeBook;
var myBookContents = app.activeBook.bookContents;
for(k=0; k<myBookContents.length; k++)
{
var myTotalContents = myBookContents
.fullName.toString() app.open(File(myTotalContents))
changeFont("Minion Pro", "Adobe Caslon Pro")
}
function changeFont(currFont, ChangeFont)
{
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.appliedFont = currFont;
app.changeTextPreferences.appliedFont = ChangeFont;
app.activeDocument.changeText();
app.findTextPreferences = app.changeTextPreferences = null;
}
Thanks
Siraj
Copy link to clipboard
Copied
Hi Siraj, and thanks for the prompt response!
I'm getting the following error popup when trying to run your script:
then as you can see it simply opens up the Find Font error message and I have to manually replace each one as before.
Any ideas?
Copy link to clipboard
Copied
Also, I see that I may have not explained my issue clearly from the beginning... I'm wanting to replace these missing fonts with my own installed fonts from my system that are virtually the same, just named a bit differently for some reason. I run into this frequently it seems, especially with my colleagues who work on Mac, as I'm on PC. For example, ID tells me I don't have Helvetica Neue (T1) 56 Italic, but I do have Helvetica Neue Italic, and since there's virtually no difference in the font, it's safe for me to go ahead and swap it with the version I have installed. I hope I'm making sense. So we're not dealing with simply swapping fonts, but replacing missing fonts with my existing ones.
Copy link to clipboard
Copied
Hi Andy,
In my end code is works well.
Please provide the "find font" list and "change font" list.
I will test in my end too.
Meanwhile time, please be ensure your end too.
Copy link to clipboard
Copied
Hi BEGINNER_X,
The missing fonts are on the left, and the ones I'd like to replace them with are on the right:
Helvetica Neue Light Italic > Helvetica Neue LT Std 46 Light Italic
ITC Officiana Sans > ITC Officiana Sans Std Book
Adobe Garamond Bold > Adobe Garamond Pro Bold
Copy link to clipboard
Copied
Hi Siraj,
I would think that you must restrain the missing fonts warning at the beginning of the script with:
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
and set it back to 'INTERACT_WITH_ALL' at the end.
Kai
Copy link to clipboard
Copied
Hi Andy,
Kai: Thank You for your tips.
Below code may it will helpful for you:
if(app.books.length==0)
{
alert("please open the book")
exit(0);
}
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
var myBook = app.activeBook;
var myBookContents = app.activeBook.bookContents;
for(k=0; k<myBookContents.length; k++)
{
var myTotalContents = myBookContents
.fullName.toString() app.open(File(myTotalContents))
try{
changeFont("Akzidenz-Grotesk BQ", "Italic", "Adobe Caslon Pro", "Italic")
}
catch(e){}
}
function changeFont(currFont, currFontStyle, ChangeFont, ChangeFontStyle)
{
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.appliedFont = currFont;
app.findTextPreferences.fontStyle = currFontStyle
app.changeTextPreferences.appliedFont = ChangeFont;
app.changeTextPreferences.fontStyle = ChangeFontStyle
app.activeDocument.changeText();
app.findTextPreferences = app.changeTextPreferences = null;
}
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
Thanks
Siraj