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:
| nome | fonte | horizontal scale | vertical scale | cor | % de cor | baseline shift | linguagem | basedo em | |
| vverbete.lexeger.exeger.tbreg | helvetica lt std | light condensed | 100 | 100 | c=0 m=70 y=0 k=0 | 100 | 0 | portuguese: orthographic agreement | [none] |
| efaux3 | helvetica lt std | roman | 100 | 100 | c=100 m=0 y=0 k=60 | 100 | 0 | portuguese: orthographic agreement | [none] |
| efaux4 | lucida math std | symbol | 100 | 100 | c=20 m=100 y=50 k=0 | 100 | 0 | portuguese: orthographic agreement | [none] |
| vverbete.divisao.catgram.aceps.num | itc novarese std | bold | 100 | 100 | c=0 m=100 y=100 k=0 | 100 | 0 | portuguese: orthographic agreement | [none] |
| vverbete.divisao.catgram.aceps.subacep.traduz.trad_i | frutiger lt std | 46 light italic | 100 | 100 | c=100 m=0 y=0 k=20 | 100 | 0 | portuguese: orthographic agreement | [none] |
| vverbete.divisao.catgram.aceps.subacep.traduz.trad_ib | frutiger lt std | 66 bold italic | 100 | 100 | c=100 m=0 y=0 k=50 | 100 | 0 | portuguese: 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
Post a Comment