Copy link to clipboard
Copied
Is it possible for AppleScript to automatically fetch needed fonts from TypeKit for InDesign CC? Moving from CS6 to CC 2017, this is becoming a problem because a script batch processes books and magazines to output overnight the PDFs for print and digital publications, but an increasing number of documents are tagged for manual processing in the morning because a designer used a TypeKit font that must be manually loaded onto the Production Mac before it can export the PDFs. I've hit a roadblock since a search for the word "typekit" in ID's AppleScript dictionary found no results.
As a backup plan, is there a simple way for an AppleScript to parse ID docs to gather a list of TypeKit fonts used before they're queued for output?
Thanks much for any advice -- Rick
Hi Rick,
I can only provide some hints with ExtendScript.
And a workaround that can be used to write a log of missing fonts.
What you could perhaps do is re-setting the user interaction level in the script preferences of the app temporarily:
// ExtendScript scripting:
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
That would suppress the Typekit alert.
Then test for missing fonts.
Hope you can transpose that to AppleScript:
...var usedOnes = app.documents[0].fonts.everyIt
Copy link to clipboard
Copied
Hi Rick,
I can only provide some hints with ExtendScript.
And a workaround that can be used to write a log of missing fonts.
What you could perhaps do is re-setting the user interaction level in the script preferences of the app temporarily:
// ExtendScript scripting:
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
That would suppress the Typekit alert.
Then test for missing fonts.
Hope you can transpose that to AppleScript:
var usedOnes = app.documents[0].fonts.everyItem().getElements();
for(var n=0;n<usedOnes.length;n++)
{
if(usedOnes
.status !== FontStatus.INSTALLED) {
$.writeln(n+"\t"+usedOnes
.status.toString()+"\t"+usedOnes .fontFamily+"\t"+usedOnes .fontStyleName); }
};
After looping don't forget to reset the user interaction level in the script preferences:
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
Regards,
Uwe
Copy link to clipboard
Copied
Thanks, Uwe,
I marked your answer as Correct because it's likely as correct as possible, all things considered.
Scripting the UI through System Events didn't work because the new dialogs don't have items AppleScript can access, so if a dialog pops up asking to sync any missing TypeKit fonts, it looks to AppleScript like a blank window with no properties.
I took an approach similar to what you suggested, although with an attempt to distinguish TypeKit fonts from ordinary ones by inspecting the properties for font type "OpenType CFF," "allow PDF embedding," "allow editable embedding," and the font location. It's puzzling that sometimes these properties can't be accessed and generate an error, while other times using the same computer, same file, same situation, it works. The surest method is when the font location includes the phrase "TypeKit" but more often it gives a path to a different installed font. The first three properties mentioned are all true for TypeKit, but not only for TypeKit. To make things even more interesting/challenging, exporting the file to PDF, even if the computer is licensed for TypeKit but doesn't actually have the font, it can still export PDFs with the missing font included, thanks (I believe) to the 2nd and 3rd properties mentioned. Whether we can rely on this is yet to be proven, at least by our own experiments.
Perhaps a future version of CC will make it easier for scripts to reliably identify TypeKit fonts, whether installed or missing/substituted.
Thanks again!
Rick
Copy link to clipboard
Copied
set thefile to choose file with prompt "Please choose a file:"
tell application "Adobe InDesign CC 2018"
set user interaction level of script preferences to interact with all
open thefile
delay 3
tell dialog "Missing Fonts"
activate
end tell
end tell
tell application "System Events"
tell application process "indesign"
delay 1
keystroke (ASCII character 9)
delay 3
keystroke (ASCII character 32)
end tell
end tell