2 Replies Latest reply on Apr 9, 2009 6:36 AM by littlemookie

    Change Font in Paragraph Style Script?

    littlemookie Level 1

      Does anyone know if there is a script to go through the Paragraph Styles and change font from to another?


      Also, if there is one to reduce the font/leading size either at the same time or in two seperate scripts, that would be utra sweet.


      Thanks to anyone who can help in advance.



        • 1. Re: Change Font in Paragraph Style Script?
          [Jongware] Most Valuable Participant

          I don't know if there is a script to do this, so here's one I just made up. It's assuming you are using CS3 (you don't mention a version), and there are tiny differences between ID versions, so it might not run straight away.


          for (var i=2; i<app.activeDocument.paragraphStyles.length; i++)
          app.activeDocument.paragraphStyles[i].appliedFont = "Helvetica";
          app.activeDocument.paragraphStyles[i].pointSize *= 0.80;

            if (app.activeDocument.paragraphStyles[i].leading != Leading.AUTO)
               app.activeDocument.paragraphStyles[i].leading *= 0.80;

          It skips the first 2 paragraph styles because those are '[None]' and [Basic Paragraph]', and, reportedly, it's bad karma to mess with those.


          The first line inside the loop simply sets the font. An additional style specifier (for example, "Regular", "Bold") is left out because you might have something already there. Notice that if you try to change "Helvetica Bold" to, say, a Frutiger, it will not be correct first time round -- Frutiger does not have a "Bold", it's called "65 Bold" for that family. Well, you can't win'em all.


          The second line takes the current defined point size and multiplies this with 0.80, resulting in a new size 80% of the previous one.


          The 3rd & 4th lines first test for a possible complication. If your leading is set to Automatic, you don't have to make it smaller (even worse: the JavaScript tries to multiply Leading.AUTO by 0.80, and will bomb out with an error). Only when set to a fixed value, it'll reduce to 80%.

          • 2. Re: Change Font in Paragraph Style Script?
            littlemookie Level 1

            Hey dude,


            That's it! Cheers, you've saved me a hell of a lot of time and effort. Many thanks dude!


            To notch.