2 Replies Latest reply on Apr 19, 2017 10:51 AM by Rick E Johnson

    Fetching fonts from TypeKit with AppleScript

    Rick E Johnson Level 1

      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

        • 1. Re: Fetching fonts from TypeKit with AppleScript
          Laubender Adobe Community Professional & MVP

          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[n].status !== FontStatus.INSTALLED)


          After looping don't forget to reset the user interaction level in the script preferences:


          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;



          1 person found this helpful
          • 2. Re: Fetching fonts from TypeKit with AppleScript
            Rick E Johnson Level 1

            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!