Copy link to clipboard
Copied
Hi all,
This one's been driving me a bit crazy. End goal is to do a find/replace missing font by CSV, but having inconsistent results with how certain document.fonts are being identified and found. Also seeing inconsistencies across OSes (I am on Mac 10.15.6, running InDesign 16.0.1). I am unable to find some of the T1 fonts, and their names display just as Helvetica, not Helvetica Neue (T1).
I had someone test on High Sierra, InDesign 15 and had no problem finding and replacing all the fonts. Also been having issues on Windows 10, ID 16.1, my client's machine. They were able to find a couple of the T1 fonts, but not all. Their log file is attached.
I'm curious if others wouldn't mind testing on the attached idml and sharing their log file with me to see if I can get to the root of the issue. Potentially a move away from TrueType font support already? Pardon some of the inefficiences in the code; just trying to solve this bug and cobbled together snippets from the main codebase I'm working on.
Much appreciated.
var logger = function(msg) {
try {
//var d = new Date();
var f = File("~/Desktop/fontReplacer-log.txt");
f.encoding = "UTF-8";
f.open("a");
f.writeln(msg);
f.close();
}
catch(e) {
}
};
var main = function() {
var usedFonts = app.activeDocument.fonts;
var numFonts = usedFonts.length;
logger("Used fonts: " + numFonts);
var missingFonts = [];
for ( var i = numFonts - 1; i >= 0; i-- ) {
logger("-------------");
logger(usedFonts[i].name);
if ( usedFonts[i].status != FontStatus.INSTALLED ) {
logger("Font is missing");
//missingFonts.push(usedFonts[i]);
}
var myFontFamily = usedFonts[i].fontFamily;
//---------------------------------------------------------------------------------------------------------
var myFontStyle = usedFonts[i].name.replace(/.+\t/,"").replace(/(.+)(\1)/,"$1");
//---------------------------------------------------------------------------------------------------------
logger( "Found:\tmyFontFamily = " + myFontFamily + "\tmyFontStyle = " + myFontStyle )
app.findChangeTextOptions.includeMasterPages = true;
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.appliedFont = usedFonts[i];
app.findTextPreferences.fontStyle = myFontStyle;
myFound = app.activeDocument.findText();
var F = myFound.length;
app.changeTextPreferences.appliedFont = "Minion Pro";
app.changeTextPreferences.fontStyle = "Regular";
app.activeDocument.changeText();
logger( "Done! [" + F + "]" )
}
alert("Done!");
}
main();
Copy link to clipboard
Copied
Here are results from the log from my machine just now. Having trouble uploading the idml; getting this error message:
Here's a DB link to the IDML.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Interesting result. You had successful finds for everything but:
Thanks for testing.
Copy link to clipboard
Copied
Disregard, figured out why some were skipped; it was a problem with the iterator. Only question left is why the two instances of 57 Condensed. I fixed the code above to fix the iterator issue, for anyone else who might be able to test.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks, Luis. OS and ID Version?
Copy link to clipboard
Copied
I found that using doc.fonts is unreliable if you check for missing fonts.
I used it on an export script which regulary found "missing" fonts which in fact weren't (e.g. some Helvetica).
I switched to using a preflight profile which checks for missing fonts and catch the result from there (for some output info).
Nevertheless, attached my log (macOS 10.13.6, InDesign 15.1.3)