Copy link to clipboard
Copied
Hi,
We've recently changed the fonts we use for all of our company collateral. We are changing from an old, outdated TT file set of Helvetica Neue to the current OT family that Linotype offers. Same face, different font files.
Every * little * thing * we publish uses these fonts and now I have the problem of updating tens of thousands of native files with the new font links. Is there a way universally update in InDesign and Illustrator so that my native files using font set A automatically update to font set B? I don't want to loose hours of my life clicking around in individual files to relink everything.
I've done some poking around and not found any answers to this question. Any help or redirect would be appreciated.
Thanks,
AR
[Changed from Discussion to Question by moderator]
I've made a new version. Now the user can prepare a list of the fonts to be changed, say in Excel (optionally), and save it as CSV-file which will be used by the script, or you can edit it directly in the CSV-file using a plain text editor like Notepad (PC) or TextEdit (Mac).
— Kas
Copy link to clipboard
Copied
I've moved this thread from the (fairly quiet) Type & Typography since this isn't really a question about type, but more of a question about how to use Adobe software. Thus it is now in a product-specific support forum. I would recommend you create a post in the Illustrator forum as well since the answer is likely to be different for each software.
That being said, perhaps this would be a question for Illustrator Scripting or InDesign Scripting, but I'm not familiar enough with either of them to know for sure.
Copy link to clipboard
Copied
I hope you work with a logical build up Paragraph and Character styles with the very same name in every document. Import these styles from a clean source document and overwrite the existing styles. Otherwise, you have to do the hard work, document by document with find and replace font, and replace them.
Copy link to clipboard
Copied
For InDesign documents you can use Type>Find Font... (not Find/Change) which lets you change a document's fonts with the option of updating any styles that use the font with one click. It is certainly scriptable and one likely exists, so ask in the scripting forums.
Copy link to clipboard
Copied
It looks like a very interesting idea for making a script.
I wrote a quick & dirty script for changing fonts which should be used together with my new Batch processor.
Here I posted the script and before and after sample documents (ver. CC 2017).
In the future I'm going to make a more user friendly version so the user could prepare a list of the fonts to be changed, say in Excel (optionally), and save it as CSV-file which will be used by the script. But so far you have to make minor edits to the script:
At the very beginning you'll see the first variable which is the array of arrays containing the names of the fonts in the format
[ "Find this", "Change to this" ],
Here I used the fonts installed with InDesign to make sure that everybody have them and can test the script using my sample.
The left element is 'Find this', the right one is 'Change to'.
The family name and font style should be separated by a tab: either \t or by actual tab (by hitting tab on the keyboard)
The find-change pairs (the elements of array) are separated by commas so make sure that you won't leave a comma after the last element (see the screenshot above).
Then you can select the script in the Batch processor like so:
The 'change fonts' script does the following:
The script changes Minion Pro - Bold, Italic and Bold Italic to Myriad Pro (Letter Gothic Std obviously is left unchanged).
Before
After
Here's the script:
var fontList = [
["Minion Pro\tRegular", "Myriad Pro\tRegular"],
["Minion Pro\tBold", "Myriad Pro\tBold"],
["Minion Pro\tItalic", "Myriad Pro\tItalic"],
["Minion Pro\tBold Italic", "Myriad Pro\tBold Italic"]
];
main();
function main() {
try { // if something goes wrong in the try-catch block, the batch processor won't stop here. It will log the error message and continue further
var newFont, paragraphStyle, characterStyle,
doc = app.activeDocument, // The frontmost document
paragraphStyles = doc.allParagraphStyles,
characterStyles = doc.allCharacterStyles;
// Change in paragraph styles
for (var p = 1; p < paragraphStyles.length; p++) {
paragraphStyle = paragraphStyles
;
newFont = getNewFont(paragraphStyle.appliedFont.name);
if (newFont != null) {
paragraphStyle.appliedFont = newFont;
}
}
// Change in character styles
for (var c = 1; c < characterStyles.length; c++) {
characterStyle = characterStyles
; newFont = getNewFont(characterStyles
.appliedFont + "\t" + characterStyles .fontStyle); if (newFont != null) {
characterStyles
.appliedFont = newFont; }
}
for (var i = 0; i < fontList.length; i++) {
var changed;
app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;
app.findTextPreferences.appliedFont = fontList[0];
app.changeTextPreferences.appliedFont = fontList[1];
changed = doc.changeText();
app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;
}
}
catch(err) { // if an error occurs, catch it and write the document's name, error message and line# where it happened into the log
gErrorLog.push(doc.name + " - " + err.message + ", line: " + err.line);
}
}
function getNewFont(oldFontName) {
var newFont = null;
for (var p = 0; p < fontList.length; p++) {
if (oldFontName == fontList
[0]) {
newFont = app.fonts.itemByName(fontList
[1]);
if (!newFont.isValid) {
newFont = null;
}
break;
}
}
return newFont;
}
Hope this helps.
— Kasyan
Copy link to clipboard
Copied
Hi Kasyan,
thank you for posting this.
Maybe you could use the arrays allParagraphStyles and allCharacterStyles to include cases where the styles are stored in groups.
Thanks,
Uwe
Copy link to clipboard
Copied
Hi Uwe,
I do use them in the script.
Regards,
Kasyan
Copy link to clipboard
Copied
Oops… Sorry. Did not check that…
Lines 15 and 16.
Uwe
Copy link to clipboard
Copied
Another, maybe safer, script strategy would be modify the find and change script to be a startup script with no save line. So it would check docs on open for the old Helevetica and if an instance exists, make the change and throw up a warning dialog. Then it would be up to the user to check the file before saving.
Copy link to clipboard
Copied
I think my approach is quite safe: with the 'Backup original documents' check box ON, the batch processor never overwrites the originals, even if you run the script many times.
The screenshot above illustrates what happens after running it 5 times:
Backup_Test-Before.indd -- is the original version
Test-Before.indd -- is the latest version
Backup(X)_Test-Before.indd -- intermediate versions
— Kas
Copy link to clipboard
Copied
You are making a terrible assumption here, that the “old, outdated TT file set of Helvetica Neue” that you currently have installed and are using is really the exact same font as “the current OT family that Linotype offers.”
Ignoring all the wonderful advise offered by other contributors to this thread, you should be aware that just because the name Helvetica Neue is the same, you cannot assume that the font metrics and the encodings are the same.
Differences in metrics including set widths of particular characters and pair kerning tables may very well lead to different line and page breaks.
Differences in encodings between the old and new fonts may result in the wrong characters and/or the .notdef glyph (the box with the X in it) displaying and printing after you actually do the substitution.
You will need to go through your documents and look for these possible discrepancies!
- Dov
Copy link to clipboard
Copied
I've made a new version. Now the user can prepare a list of the fonts to be changed, say in Excel (optionally), and save it as CSV-file which will be used by the script, or you can edit it directly in the CSV-file using a plain text editor like Notepad (PC) or TextEdit (Mac).
— Kas
Copy link to clipboard
Copied
Hi Kasyan Servetsky
Thanks for a great script!
But i have a question: I have a font called Gotham (T1) Regular.
Written like this on the csv-file:
Gotham (T1)\tMedium Helvetica\tRegular
But the font is not recognised by the script, and not beeing replaced.
Should i write it in another way or do you have any idea?
Thanks in advance and have a nice weekend! Best regards, Fred
Copy link to clipboard
Copied
Hi Fred,
I guess you have two fonts on your system whose name is Gotham: indicated by (T1) and (TT). This means Type 1 (PostScript) and TrueType font.
Try to uninstall one of them and use the following line:
Gotham\tMedium Helvetica\tRegular
— Kasyan
Copy link to clipboard
Copied
Hi Kasyan Servetsky
Thanks for answering.
I only have otf versions of Gotham installed.
Added this line to the csv-file but is not working neither:
Gotham\tMedium Helvetica\tRegular
Gotham (T1)\tMedium Helvetica\tRegular
So that was not the problem. Sorry.
Any other ideas?
Br, Fredrik
Copy link to clipboard
Copied
I have to debug the script to see what is going on and how to fix it. Could you tell me the font file name so I could check if I have it in my font collection?
At the moment I'm busy with finishing the current issue of our magazine so I can look into this during the weekend.
Also, check out this page for alternative versions of the script.
— Kasyan
Copy link to clipboard
Copied
Hi!
The problem is that it is a font that i don't have, and is missing in the layout (and my collection).
But i will dig into it on monday and see it i can find exactly what fint it is.
Don't debug to hard on it. The script works flawless, except just this font.
And i will look at the other versions to see if there is any other one that works better.
Cheers and have a great weekend!
//Fred
Copy link to clipboard
Copied
Hi Fred,
I made a research and found out the following:
Something has been totally broken -- a new bug was introduced -- in a version after CS3. (So far, I have no idea in which exactly version).
I tried to recreate your problem as close as possible: exported T1 version of the Gotham-Medium font, installed it, created a test file with par and char styles and local formatting using the font. Then I removed the font so it became missing. In CC 2018 (Windows), the problem occurs in the last part of the script which uses find-replace text feature to replace fonts in locally formatted text (no issues with par and char styles). I can replace a missing font in UI but can't do the same by script.
I found this script by Tomaxxi which didn't work for me in CC 2018 so I assumed that it did work in a previous version.
I tested my script in CS3 and it worked as expected using this line:
Gotham\tMedium Arial\tRegular
Off the top of my head, I suggest a couple of workarounds:
1. Create a 'mock up' font (using the missing font's name), say, in FontLab and temporarily install it for running the script only.
2. Use the snippet written by Marc you can use it as a separate script or add it to the existing one and call it like so:
app.activeDocument.changeMissingFontsBy("Helvetica\tRegular");
However, it replaces all missing fonts with one 'substitution' font (No find this -- replace with that).
Also, I think it would be possible to rework the script using Marc's approach to handle missing fonts: get the list of missing fonts, loop through the all text style ranges in all stories and replace them according to the 'replacement table'.
Regards,
Kasyan
Copy link to clipboard
Copied
P.S. I think it has been already broken back in CS5: see this thread.
— Kas
Copy link to clipboard
Copied
Ah, thanks for look ing into this.
Well most if the script works perferct anyway.
Cheers, Fredrik
Copy link to clipboard
Copied
As Kasyan points out, things are seriously broken when it comes to searching and replacing fonts in a document, especially when they have similar names or when old fonts are missing.
I wrote a fairly complex script for the New York Times last year to deal with all these issues. Like you, there were converting a large amount of ancient templates, and needed the fonts updated to their latest versions in all those templates, and we had this crazy thing that no matter what, some fonts just wouldn't get replaced.
In the end, the solution was to get the script to export each file to IDML, crack it open, modify the font names there, re-zip, and then change the paragraph and character styles. And even that required some extra steps in the middle.
You'll also, presumably, be wanting to modify paragraph and character styles to be using the new fonts, and things get fun when some paragraph styles are based on others...!
Ultimately, though, we managed to get the whole thing to work... The end result was a Mac droplet -- whenever an old file needed to be updated, it would be dragged onto the droplet, and after a few moments would open in InDesign with all the fonts replaced (they preferred that to batch-modifying all the old docs, although both approached are equally valid).
Ariel