Automatically Output Font List across multiple files?
Copy link to clipboard
Copied
This may not even be something that can be done within Illustrator (maybe Bridge?), I'm not entirely certain. Essentially what I would like to do is a batch command that would go through multiple files and output a list of fonts that are used in each Illustrator file. I know inside of Illustrator, you can go into the 'Find Fonts' dialogue and 'Save List' and have it output a txt file with all the fonts listed in there, but doing that across hundreds/thousands of files can get a little cumbersome, so I'm trying to figure out an alternate way to do that same thing across many files.
Explore related tutorials & articles
Copy link to clipboard
Copied
give the script in this post a try, it's written for eps files though, change it to search for ai files.
Copy link to clipboard
Copied
I was able to get the script setup and loaded as a jsx file (also swapped .eps for .ai)and it appears to at least fire off correctly inside of Illustrator. It's asking for a folder and it outputs a Font.info.txt file, however it's erroring out with the message "Unable to load the AdobeXMPScript Library!" and the text file is just left blank, so I'm assuming something in there isn't going through correctly.
This is the version I used:
#target illustrator
var inputFolder = Folder.selectDialog("Select a folder contains '*.ai' files ");
if (inputFolder) {
var fileList = inputFolder.getFiles('*.ai'),
fontsInfo = [];
loadXMPLibrary();
for (var i = 0; i < fileList.length; i++) {
if (fileList instanceof File && fileList.hidden == false) {
fontsInfo.push(getFontsInfo(fileList));
}
}
unloadXMPLibrary();
}
var Loginfo = new File(inputFolder + '/Font.info.txt');
Loginfo.open('w', 'TEXT', '????');
var info = fontsInfo.join('\n\n');
Loginfo.write(info);
Loginfo.close();
if (/(Open Type|TrueType)/.test(info)) {
alert('Open Type / TrueType font found, see log file for details!')
}
function getFontsInfo(file) {
var arr = ['File: ' + decodeURI (file.name)],
xmpFile, oXmp, fontNumber, i, path, fontname, fonttype, ns = 'http://ns.adobe.com/xap/1.0/t/pg/';
xmpFile = new XMPFile(file.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);
oXmp = xmpFile.getXMP(); //Returns an XMPMeta object
fontNumber = oXmp.countArrayItems(ns, 'xmpTPg:Fonts');
xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
if (fontNumber) { // if there's at least 1 font, proceed
for (i = 1; i <= fontNumber; i++) {
path = XMPUtils.composeArrayItemPath(ns, 'xmpTPg:Fonts', i);
fontname = oXmp.getStructField(ns, path, XMPConst.TYPE_FONT, 'fontName');
fonttype = oXmp.getStructField(ns, path, XMPConst.TYPE_FONT, 'fontType');
arr.push([i, '. ', fontname, '-', fonttype].join(''));
}
}
return arr.join('\n');
}
function loadXMPLibrary() {
if (!ExternalObject.AdobeXMPScript) {
try {
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
} catch (e) {
alert('Unable to load the AdobeXMPScript library!');
return false;
}
}
return true;
}
function unloadXMPLibrary() {
if (ExternalObject.AdobeXMPScript) {
try {
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
} catch (e) {
alert('Unable to unload the AdobeXMPScript library!');
}
}
}
Copy link to clipboard
Copied
As you already assumed, Bridge will show a list of all used fonts in its Metadata section.
So, you may just use Bridge.
Copy link to clipboard
Copied
With this I need to be able output these into a text file for compiling a list. I didn't see any way inside of Bridge to actually export the metadata, it ony seems to show it.
Copy link to clipboard
Copied
In Bridge, you can export it as an .xmp file (which is essentially a plain .txt file).
See File menu > File Info and in the following dialog you can export it (see options at the bottom of the dialog).
In case it does matter, you can rename the file to xyz.txt and extract just the font infos, if required.

