Help! I need somebody! Help!


i'm new scripting adobe programs , i'm less new javascript. i've got bit of code user moluapple - incredibly helpful in getting me started. i'm having trouble understanding code. don't know parts , i'm having trouble finding definitions of terms online - there disconnect between scripting adobe , regular javascripting?

 

the code works collect fonts in open illustrator document. issue having collects 1 font. or collect whole font family. haven't been able collect of fonts in document.

 

i hoping put finger on i'm doing wrong. , me understand how code works.

 

any apreciated. know i'm asking huge favor.

 

 

-----------------------------------------

 

 

function getusedfonts (doc){

     var xmlstring = new xml(doc.xmpstring),

     fontfamily = xmlstring.descendants("stfnt:fontfamily"),

     fontface = xmlstring.descendants("stfnt:fontface"),

     ln = fontface.length(), = 0, arr = [];

     (; i<ln; i++){arr.push(fontfamily[i] + '\t' + fontface[i])};

     return arr;

}

alert(getusedfonts(activedocument));

 

function main() {

          var

                    doc = app.activedocument,

                    docpath = doc.path,

                    arr = getusedfonts (doc),

                    ofolder = new folder(docpath + '/documentfonts'),

                    btmsg,

                    packagefonts = function (string, ofolder) {

                              var arr = string.split(','), opath, ofile, oname, i;

                              (i=0; i<arr.length; i++){

                                        opath = app.fonts.itembyname(arr[i]).location;

                                        ofile = file(opath);

                                        oname = ofolder + '/' + arr[i].replace ('          ', ' ').replace(' regular', '') +

                                                  opath.substring(opath.lastindexof('.'), opath.length);

                                        ofile.copy(file(oname), true);

                              }

                    };

          ofolder.create();

          btmsg = new bridgetalk();

          btmsg.target = "indesign";

          btmsg.body = packagefonts.tosource() + '("' + arr +'", "' + ofolder + '")';

          btmsg.onresult = function (resultmsg) {

                    $.writeln("result = " + resultmsg.body);

          }

          btmsg.onerror = function (errormsg) {

                    $.writeln("error = " + errormsg.body);

          }

          btmsg.send();

}

 

 

main();

i not scripting expert, can see script seems have been written indesign, not illustrator.

 

you target indesign line:

 

     btmsg.target = "indesign";



More discussions in Illustrator Scripting


adobe

Comments

Popular posts from this blog

how to devide a circle into equal parts

"Could not fill because there are not enough opaque source pixels" - not solved by any other thread

Why can't I change the billing info for my account?