Skip to main content
Inspiring
July 26, 2023
Question

How to collect/package fonts using Javascript?

  • July 26, 2023
  • 2 replies
  • 1088 views

Hi,

 

I need to collect all font files used in an active document in Adobe Illustrator. By looking at the XML header, I'm able to create a list of fonts used in a document, but I can't locate the full path to the font file.

 

How do I locate the full path of the fonts used in a file? How does the "package" feature is able to collect the fonts?

 

Thank you

This topic has been closed for replies.

2 replies

m1b
Community Expert
Community Expert
July 26, 2023

Edit: this info is for Indesign, sorry.

---

Hi @tmmls, you should be able to get the path to the font file using the location property of the Font.

- Mark

 

 

var font = app.fonts.itemByName('Arial\tBold'),
    path = font.location;

$.writeln(path);

 

tmmlsAuthor
Inspiring
July 26, 2023

Hi Mark,

 

It seems that Illustrator does not have an app.fonts, but an app.textFonts. And a TextFont object has no location property.

 

I have found another approach to maybe solve this. By making a BridgeTalk connection, I can probably do it with Indesign as well. However, if I could only do it with Illustrator, that would be a better choice

m1b
Community Expert
Community Expert
July 26, 2023

Hi @tmmls, stupid me! On my phone, because of the forum UI, I can't easily see if it is an Illustrator or Indesign question. BridgeTalk/Indesign is a clever workaround.

- Mark

Disposition_Dev
Legend
July 26, 2023

youre looking to do this with a script? not via the File > Package... option?

 

i dont know of any way to get the full path of a font... but in theory they should be coming from a specific place. so you could hard code the path to your system fonts (or whatever folder your font manager uses) and then get the font name from the api by looping all the textFrames in the document, making an array of the font names, via the TextFrameItem.textRange.textFont.name property, then write a text file with the full paths to each unique font name.