1 Reply Latest reply on Aug 28, 2009 2:23 AM by [Jongware]

    apply different font styles in single text frame


      hi all


      how can i apply different font styles in a single text frame using indesign script ?


      for example :




      may i know is it possible to do that and how to do that ?



        • 1. Re: apply different font styles in single text frame
          [Jongware] Most Valuable Participant

          You can set (as well as read) every single property of any text range with scripts. This is javascript; it assumes you text cursor is inside a frame with some text.


          * Setting some specific characters to a color:

          app.selection[0].parentStory.characters.itemByRange(5,10).fillColor = "Red";


          * Change the font of words:

          app.selection[0].parentStory.words[3].appliedFont = "Arial\tBold";

          * .. or just the style:

          app.selection[0].parentStory.lines[2].fontStyle = "Italic";


          * .. or any other attribute (this one requires you to have at least 5 characters selected):

          app.selection[0].characters[5].underline = true;

          Of course these operations are not limited to something you select; they work the same with any text frames you can refer to.


          app.activeDocument.textFrames[1].paragraphs[2].appliedCharacterStyle = "charstyle";