1 Reply Latest reply on Dec 19, 2014 8:11 PM by Chinnadk

    Randomly generate individual fonts in body text

    MarcusWhittle

      HI i would like to randomly have different typeface for each letter in a word through out body text using the fonts that i have on my laptop! Like the image below, can anyone help?detail_002_IMG_2684-1024x768.jpg

        • 1. Re: Randomly generate individual fonts in body text
          Chinnadk Level 4

          Try this,

           

          var doc = app.activeDocument,
              _fonts = app.fonts.everyItem().getElements(),
              _stories = doc.stories.everyItem().getElements();
          
          for(var i=0;i<_stories.length;i++)
          {
                  var _char = _stories[i].characters.everyItem().getElements();
                  for(var j=0;j<_char.length;j++)
                  {
                          try{
                              _char[j].appliedFont = app.fonts.item(Math.floor(Math.random() * _fonts.length) + 1)
                          }
                          catch(e){}
                      }
              }
          

           

          Regards,

          Chinna