3 Replies Latest reply on Sep 15, 2016 6:11 AM by tpk1982

    reduce text size in a frame with overset text

    jakec88782761 Level 2

      Hi,

       

      I'm trying to write a script that reduces the text size for overset text by 0.5 pts.

       

      var myTextFrame = app.activeDocument.textFrames.everyItem();

      while(myTextFrame.overflows){

      myTextFrame.parentStory.pointSize -= 0.5;

      }

       

      This seems to be an infinite loop but I cant tell why.

       

      Any help would be great

        • 1. Re: reduce text size in a frame with overset text
          [Jongware] Most Valuable Participant

          When you do this manually you can see the text change and reflow with each adjustment, but in a script, InDesign needs a bit of time to process the instructions. Usually, adding an explicit 'recompose' after each change fixes this.

           

          However ... that still did not work. I think the 'everyItem' notation you are using here does not like it. I suggest two changes: first, don't use 'everyItem', and second, you don't need to check each text frame. You see a text frame overflow but it's actually the story that does this. You only need to check all stories:

           

          for (i=0; i<app.activeDocument.stories.length; i++)
          {
          while(app.activeDocument.stories[i].overflows){
            app.activeDocument.stories[i].pointSize -= 0.5;
            app.activeDocument.stories[i].recompose();
          }
          }
          

           

          (Note that all text in the story gets the same size. I hope that is not a problem with your text.)

          • 2. Re: reduce text size in a frame with overset text
            jakec88782761 Level 2

            Thanks

             

            I'm confused as to what recompose() does. There's no description in the OMV.

             

            Also, if I wanted to reduce the point size of each paragraph style separately, is it possible to use this script with a loop that find all the paragraph styles and reduces the point size of the paragraph styles instead?