3 Replies Latest reply on May 28, 2011 9:56 PM by zyberkid

    applying charecter style for dynamic running text, with different languages

    zyberkid Level 1

      hi,

      i am using the following method for applying style,

      activeTextFrame.parentStory.insertionPoints[-1].appliedCharacterStyle = app.activeDocument.characterStyles.item("languageTextStyle");
      activeTextFrame.parentStory.insertionPoints[-1].contents = textValue;

       

      i have the following scenario,

       

      i get many languages text from an array, for each language text i need to apply different font face, lead space, font size, etc.

       

      // inside  a loop gets different text and different languages
      try{
                     langStyle = app.activeDocument.characterStyles.add({name:'languageTextStyle'});
                     }
                     catch(e)
                     {
                          debugInfo += "\n  Oops style already added? : " + "languageTextStyle" ;
                          langStyle = app.activeDocument.characterStyles.itemByName("languageTextStyle");
                          }

                     //     trying to apply the font
                     try
                     {
                         
                          langStyle.appliedFont = app.fonts.item(fontName);//(this.productNameFont);
                          debugInfo += "\n  fontName : " + fontName ;
                     }
                     catch(e)
                     {         
                          debugInfo += "\n missing fontName : " + fontName ;
           //     Appling alternate font
                     }

                     try
                     {
                          debugInfo += "\n bold style : " + boldStyle ;
                          if(boldStyle == "1")
                          {
                               //langStyle.fontStyle = "Bold";
                          }
                    
                     }
                     catch(e)
                     {
                          debugInfo += "\n missing bold style : " + boldStyle ;
                          //langStyle.fontStyle = "Regular";     //     appling alternate style;
                     }

                    
                     try
                     {
                          langStyle.pointSize = fontSize;     //     font size
                          langStyle.leading = lineSpace;
                          debugInfo += "\n pointSize : " + fontSize + "\t leading: " + lineSpace ;
                     }
                     catch(e)
                     {
                          debugInfo += "\n missing poitnsize : " + fontSize + "\t leading: " + lineSpace ;
                     }
                    

                     langStyle.fillColor = "Black";    
                     debugInfo += "\n fill color : ";
                    
                    
                     activeTextFrame.parentStory.insertionPoints[-1].appliedCharacterStyle = app.activeDocument.characterStyles.item("languageTextStyle");
                     activeTextFrame.parentStory.insertionPoints[-1].contents = textValue;

       

      but, the last style is applied for the entire text frame. any ideas regarding this.

       

      previously  i was trying to get the string length for the running text and apply  the style for the running text. it was working but, for some languages, its doesn't apply the correct font. missing some (boxes) for some  chinese

      texts .