0 Replies Latest reply on Aug 6, 2014 7:18 AM by kanaga kumar

    Font Name replaced in Template

    kanaga kumar Level 1

      Dear Friends,


      The below script pickup from forum (script created from chinna), in this script runned only in content document. But i need font name changed (paragraph and character style fonts) in Template file. Please see the screen shot for my requirement.



        var doc=app.activeDocument;

          var myDialog= new Window("dialog","Font replacer");

          var grp1=myDialog.add("group");

          var panel1=grp1.add("panel",undefined,"Find font:");

          var panel2=grp1.add("panel",undefined,"Change font:");



          var docfonts=doc.fonts.everyItem().name.join("\r").replace(/\t/g,":").split("\r");


          var appfonts=app.fonts.everyItem().name.join("\r").replace(/\t/g,":").split("\r");


          var arrayofdocfont=panel1.add("dropdownlist",undefined,docfonts);

          var arrayofappfont=panel2.add("dropdownlist",undefined,appfonts);


          var cancel = myDialog.add("button",undefined,"Cancel",{name:"cancel"});

          cancel.onClick = function (){

                  myDialog.close ();






          if(myDialog.show()) {

              var pstyles = doc.allParagraphStyles;

              var cstyles = doc.allCharacterStyles;

              var pstylefont = arrayofdocfont.selection.text.replace(/:/g,"\t").toString();


              var cstylefont = arrayofdocfont.selection.text.replace(/:.*/g,"");


              var tfont = arrayofappfont.selection.text.replace(/:/g,"\t");

              for (var a = 1; a < pstyles.length; a++) {

                  if (pstyles[a].appliedFont.name==pstylefont) {

                      pstyles[a].appliedFont = tfont;



              for (var i = 1; i < cstyles.length; i++) {

                 if (cstyles[i].appliedFont ==cstylefont) {

                  cstyles[i].appliedFont =tfont;






      Script run output screen shot:

      Screen shot 2014-08-06 at 7.43.51 PM.png




      My Requirement screen shot:

      Screen shot 2014-08-06 at 5.56.27 PM.png



      kanaga kumar. k