Create charater based on a txt file


y have text file separeted tabs definitions of charater style y want create, in font name gets error (example lucida math std , frutiger lt std.

the file exported same way, y don't undestand why. can me pleeeeeaaaase!!!

 

here's file:

 

nomefonte
horizontal scalevertical scalecor% de corbaseline shiftlinguagembasedo em
vverbete.lexeger.exeger.tbreghelvetica lt stdlight condensed100100c=0 m=70 y=0 k=01000portuguese: orthographic agreement[none]
efaux3helvetica lt stdroman100100c=100 m=0 y=0 k=601000portuguese: orthographic agreement[none]
efaux4lucida math stdsymbol100100c=20 m=100 y=50 k=01000portuguese: orthographic agreement[none]
vverbete.divisao.catgram.aceps.numitc novarese stdbold100100c=0 m=100 y=100 k=01000portuguese: orthographic agreement[none]
vverbete.divisao.catgram.aceps.subacep.traduz.trad_ifrutiger lt std46 light italic100100c=100 m=0 y=0 k=201000portuguese: orthographic agreement[none]
vverbete.divisao.catgram.aceps.subacep.traduz.trad_ibfrutiger lt std66 bold italic100100c=100 m=0 y=0 k=501000portuguese: orthographic agreement[none]

 

 

here's script:

 

main();

 

function main(){

          var myobject;

          //make user interaction (display of dialogs, etc.) turned on.

          app.scriptpreferences.userinteractionlevel = userinteractionlevels.interactwithall;

          if(app.documents.length > 0){

                    mycreatestyles(app.documents.item(0));

          }

          else{

                    alert("não existem documentos abertos. abra o documento pretendido e corra o script de novo.");

          }

}

 

function mycreatestyles(myobject){

          var myscriptfilename, mycharfile, myfindchangefilename, myscriptfile, myresult;

          var myfindchangearray, myfindpreferences, mychangepreferences, myfindlimit, mystory;

          var mystartcharacter, myendcharacter;

          var mycharfile = myfindfile("/findchangesupport/findchangelist.txt")

    var = 0;

 

 

          if(mycharfile != null){

        mycharfile = file(mycharfile);

        var mydoc = app.documents[0];

        var myresult = mycharfile.open("r", undefined, undefined);

 

 

    if(myresult == true){

           //determina o número de  estilos criar alterar

           var mycharstyles = new array();

                              do{

                myfindarray = mycharfile.readln();

                mycharstyles.push(myfindarray);

                }

            while(mycharfile.eof == false);

            var charstyleslenght = mycharstyles.length;

 

  // cria estilo lingua dos estilos de carater

          for (onestyle=1;onestyle<charstyleslenght;onestyle++){

        var mycharacterstyle = new array();

        mycharstyleprop = mycharstyles[onestyle].split("\t");

       

        var mycharstylename = mycharstyleprop[0];

        var mycharstylefont = mycharstyleprop[1];

        var mycharstylefontstyle = mycharstyleprop[2];

        mycharacterstyle = mydoc.characterstyles.add();

        mycharacterstyle.name = mycharstylename;

        mycharacterstyle.fontstyle = mycharstylefontstyle;

        mycharacterstyle.appliedfont = mycharstylefont;

       }

                              alert ("foram criados os estilos de carater.");

                    }

          }

}

function myfindfile(myfilepath){

          var myscriptfile = mygetscriptpath();

          var myscriptfile = file(myscriptfile);

          var myscriptfolder = myscriptfile.path;

          myfilepath = myscriptfolder + myfilepath;

          if(file(myfilepath).exists == false){

                    myfilepath = file.opendialog("selecione o documento .txt com palavras alterar.");

          }

          return myfilepath;

}

function mygetscriptpath(){

          try{

                    myfile = app.activescript;

          }

          catch(myerror){

                    myfile = myerror.filename;

          }

          return myfile;

}

hello paulo!

 

first qustion: error recive?

second, littel experiment, not sure help, still try it: switch lines

 

mycharacterstyle.fontstyle = mycharstylefontstyle;

mycharacterstyle.appliedfont = mycharstylefont;

 

between them

so first apply font, , font style, this:

 

mycharacterstyle.appliedfont = mycharstylefont;

mycharacterstyle.fontstyle = mycharstylefontstyle;

 

 

 

or, better, replace 2 lines (but please try first solution first , tell me if works.. i'm curious):

 

mycharacterstyle.appliedfont=mycharstylefont+"\t"+mycharstylefontstyle;



More discussions in InDesign Scripting


adobe

Comments

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account