8 Replies Latest reply on Mar 13, 2009 5:08 AM by (sandy9000)

    auto font swap

      WinXP--IDCS3,5.0.4
      Currently working on a template for multiple users and would prefer to keep only one template & script major font change. Unfortunately, I'm not a scripter, but I think this can be automated somehow. looking for a javascript to change all font family "Adobe Garamond Pro" to font family "Adobe Whatever Pro". User could then go in to script and modify with new font family name change.
      thanks
      sandy
        • 1. Re: auto font swap
          Fred Goldman Level 3
          So you want these changed in the style definition, of just in the text
          in the template?
          • 2. Re: auto font swap
            Level 1
            In the style definition would be the best.

            thanks
            sandy
            • 3. Re: auto font swap
              Fred Goldman Level 3
              Here's a start. It will loop through the files in a folder. You can
              customize it to whatever fonts and font styles you need.



              myFolder = Folder (["~/Documents/InDesign Documents"])
              myFiles = myFolder.getFiles()
              for(var i = 0; i < myFiles.length; i++){
                var myDoc =  app.open(myFiles[i])
                for(var j= 1; myDoc.characterStyles.length>j; j++){
                  if(myDoc.characterStyles[j].appliedFont ==
              "Adobe Garamond Pro"  && myDoc.characterStyles[j].fontStyle ==
              "Regular"){
                  myDoc.characterStyles[j].appliedFont = "Adobe
              Whatever Pro"
                  myDoc.characterStyles[j].fontStyle = "Regular"
                  }else{
                    if(myDoc.characterStyles[j].appliedFont
              == "Adobe Garamond Pro" && myDoc.characterStyles[j].fontStyle ==
              "Bold"){
                      myDoc.characterStyles[j].appliedFont
              = "Adobe Whatever Pro"
                      myDoc.characterStyles[j].fontStyle
              = "Bold"
                    }
                  }
                }
                myDoc.close(SaveOptions.yes,myDoc.fullName)
              }
              • 4. Re: auto font swap
                Fred Goldman Level 3
                Apparently it only works in the web view, not from a newsreader.
                • 5. Re: auto font swap
                  Fred Goldman Level 3
                  Hmm, why didn't Harbs' script poster work?



                  myFolder = Folder (["~/Documents/InDesign Documents"])
                  myFiles = myFolder.getFiles()
                  for(var i = 0; i < myFiles.length; i++){
                    var myDoc =  app.open(myFiles[i])
                    for(var j= 1; myDoc.characterStyles.length>j; j++){
                      if(myDoc.characterStyles[j].appliedFont == "Adobe Garamond Pro"  && myDoc.characterStyles[j].fontStyle == "Regular"){
                      myDoc.characterStyles[j].appliedFont = "Adobe Whatever Pro"
                      myDoc.characterStyles[j].fontStyle = "Regular"
                      }else{
                        if(myDoc.characterStyles[j].appliedFont == "Adobe Garamond Pro" && myDoc.characterStyles[j].fontStyle == "Bold"){
                          myDoc.characterStyles[j].appliedFont = "Adobe Whatever Pro"
                          myDoc.characterStyles[j].fontStyle = "Bold"
                        }
                      }
                    }
                    myDoc.close(SaveOptions.yes,myDoc.fullName)
                  }
                  • 6. Re: auto font swap
                    Level 1
                    harbs poster ?

                    s
                    • 7. Re: auto font swap
                      Fred Goldman Level 3
                      Harbs made a script to make posting scripts on the forum easier.

                      It shouldn't be difficult at all to customize the last script for your
                      needs.

                      1) Just change character styles to paragraph styles if that's what you need.

                      2) Fill in the correct path in the first line.

                      3) Replace the font names in quotes to the ones you want to find and
                      replace with.
                      • 8. Re: auto font swap
                        Level 1
                        Thanks Fred --
                        If I want to add paragraph styles to script as well, is this the portion of script I would copy & paste, then modify?

                        if(myDoc.characterStyles[j].appliedFont == "Adobe Garamond Pro" && myDoc.characterStyles[j].fontStyle == "Bold"){
                        myDoc.characterStyles[j].appliedFont = "Adobe Whatever Pro"
                        myDoc.characterStyles[j].fontStyle = "Bold"

                        Users will be running script on an open InDesign file, would that change beginning (path portion) of script?

                        s