Copy link to clipboard
Copied
Hi,
Am using Illustrator CS6 on Mac. Is it possible to collect fonts whatever i used in the document by scripting? I got some scripts from this forum but not effective.
I aware the packaging option available in CC2014.
But i need this for CS6. Please help.
Regards,
Karthi
Here is an example to collect activeDocuments font:
...function getFntsLst (doc){
var xmlString = new XML(doc.XMPString);
var fntFamily = xmlString.descendants("stFnt:fontFamily");
var fntFace = xmlString.descendants("stFnt:fontFace");
var fntFile = xmlString.descendants("stFnt:fontFileName");
var lst = new Array();
for (var i=0; i<fntFace.length(); i++)
lst.push([fntFamily, fntFace, fntFile]);
return lst;
}
function main() {
var dc = app.activeDocument;
var dcPth = dc.pa
Copy link to clipboard
Copied
If you have the Creative Cloud, the Package command was the first piece of candy added to CS6 to get people to move to the subscription model.
Copy link to clipboard
Copied
Thank you for the reply. But in my organization we dont have creative cloud..is it we need to update CS6 again?
Copy link to clipboard
Copied
Here is an example to collect activeDocuments font:
function getFntsLst (doc){
var xmlString = new XML(doc.XMPString);
var fntFamily = xmlString.descendants("stFnt:fontFamily");
var fntFace = xmlString.descendants("stFnt:fontFace");
var fntFile = xmlString.descendants("stFnt:fontFileName");
var lst = new Array();
for (var i=0; i<fntFace.length(); i++)
lst.push([fntFamily, fntFace, fntFile]);
return lst;
}
function main() {
var dc = app.activeDocument;
var dcPth = dc.path;
var lst = getFntsLst (dc);
var dst = new Folder(dcPth + '/DocumentFonts');
var getFnts = function (string, dst) {
var tb = String.fromCharCode(9);
var lst = string.split(',');
var pth, fl, nm;
for (var i=0; i<lst.length; i++){
pth = app.fonts.itemByName(lst+tb+lst[++i]).location;
fl = File(pth);
nm = dst + '/' + lst[++i];
fl.copy(File(nm));
}
};
if (!dst.exists) dst.create();
var bt;
bt = new BridgeTalk();
bt.target = "indesign";
bt.body = getFnts.toSource() + '("' + lst +'", "' + dst.path+'/'+dst.name + '")';
bt.onResult = function (resultMsg) {
$.writeln("Result = " + resultMsg.body);
}
bt.onError = function (errorMsg) {
$.writeln("Error = " + errorMsg.body);
}
bt.send();
}
main();
Copy link to clipboard
Copied
Hi Ten A,
Great script.. It created DocumentFonts but the fonts are not collecting..
Is it working fine at your end?
Also not sure about the line 31 that shows indesign. ( bt.target = "indesign"; ) Is it needed indesign to collect fonts?
Regards,
Karthi
Copy link to clipboard
Copied
Yes, It need InDesign.
Illustrator dose not have propaties of font path, But InDesign has location property.
Copy link to clipboard
Copied
Thank you for your prompt reply.. but i tested 3 documents but not sure why the fonts are not collected..any suggestions
Copy link to clipboard
Copied
Can you send me your AI documents?
Copy link to clipboard
Copied
Unfortunately it is a client file and not able to share, sorry. But i opened a new document, put some text frames and keyed some text. Then tried the above coding that also not collecting fonts.
Copy link to clipboard
Copied
Here is a modified version:
(function () {
var dc = app.activeDocument;
var dcPth = dc.path;
var lst = getFntsLst ();
var dst = new Folder(dcPth + '/DocumentFonts');
var getFnts = function (str, dst) { //Bridgetalk function
var lst = str.split(',');
var pth, fl, nm,num;
for (var i=0; i<lst.length; i++){
pth = app.fonts.itemByName(lst).location;
fl = File(pth);
num = pth.lastIndexOf("/");
nm = dst + '/' + pth.substring(num+1);
fl.copy(File(nm));
}
};
if (!dst.exists) dst.create();
var bt;
bt = new BridgeTalk();
bt.target = "indesign";
bt.body = getFnts.toSource() + '("' + lst +'", "' + dst.path+'/'+dst.name + '")';
bt.onResult = function (resultMsg) {
$.writeln("Finished collect.");
}
bt.onError = function (errorMsg) {
$.writeln("Error = " + errorMsg.body);
}
bt.send();
function getFntsLst(){ //make document font list function
var tmp = "";
var fLst = [];
var d = app.activeDocument;
if (d.textFrames.length>0){
for (var i=0;i<d.textFrames.length;i++){
for (var j=0;j<d.textFrames.characters.length;j++){
tmp = d.textFrames.characters
.characterAttributes.textFont.family + "\t" + d.textFrames.characters
.characterAttributes.textFont.style; if (fLst.join().indexOf(tmp)==-1){
fLst.push(tmp);
}
}
}
} else {
return "There are no textFrames.";
}
return fLst;
}
})();
Probabley, It works...
Copy link to clipboard
Copied
Hi Ten A,
Immense THANKS for revised script. But I got the following error message.
Regards,
Karthi
Copy link to clipboard
Copied
Hi, I have write 3 scripts for collect ai document fonts years ago.
2 of them need Indesign(same as @Ten A)
ExtendScripts4AI-ID/AI_ID_Package Fonts of File with ID.jsx at master · moluapple/ExtendScripts4AI-I... (This script do not need to open ai file)
and 1 need Illustrator only:
ExtendScripts4AI-ID/AI_PackageFonts v2.0.jsx at master · moluapple/ExtendScripts4AI-ID · GitHub (When run first time it will create a file which contains fonts info, and restart Illustrator.)
Hope this can be helpful to you.
Copy link to clipboard
Copied
Hi Ten A & moluapple,
Thank you so much to help me. All the scripts working fine after i reinstalled my Illustrator.
Regards,
Karthi
Copy link to clipboard
Copied
Hello @moluapple @Ten A
it is not working by collecting fonts if the fonts used from external font manager like extensis connect font or universal type client.
also is their any any we can batch process the package option in illustrator