Y have a text file separeted by tabs with the definitions of the charater style that y want to create, but in some font name it gets error (example Lucida Math Std and Frutiger LT Std.
The file was exported by the same way, so y don't undestand why. can someone help me pleeeeeaaaase!!!
Here's the 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 the script:
main();
function main(){
var myObject;
//Make certain that user interaction (display of dialogs, etc.) is 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 i = 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 a criar a alterar
var myCharStyles = new Array();
do{
myFindArray = myCharFile.readln();
myCharStyles.push(myFindArray);
}
while(myCharFile.eof == false);
var charStylesLenght = myCharStyles.length;
// cria estilo a 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 as palavras a alterar.");
}
return myFilePath;
}
function myGetScriptPath(){
try{
myFile = app.activeScript;
}
catch(myError){
myFile = myError.fileName;
}
return myFile;
}