3 Replies Latest reply on Feb 26, 2014 7:30 AM by Apod42

    Resize font to fill text box

    Apod42

      Hello,

       

      Please see the attached image - a text layer in Photoshop, with some text in it. The text fills only about half of the text box; is there a way by which using photoshop scripting I can resize the font (think of it as zooming the font) to completely fill the text box? I would also like to keep the text formatting, ie. larger fonts should stay larger.

       

      Thank you, any help would be greatly appreciated!

       

       

       

      text.jpg

        • 1. Re: Resize font to fill text box
          Apod42 Level 1

          After hours of digging through forums, I have found this thread: http://ps-scripts.com/bb/viewtopic.php?t=2422

           

          I think the script there could be an answer to my problem, I need to fit the text vertically, not horizontally, so I replaced maxWidth with maxHeight. It kinda works, it does something, but not what I need

           

          Based on the script below, how could I enlarge my text to fit a text box with a height of 1000 px?

           

          I need something similar to the result obtained when selecting all text in a tex layer and pressing " Ctrl + Shift + > "

           

          var maxWidth = 120;

          var nameLayer = activeDocument.artLayers.getByName ("text");

          var fontSize = 20;

          nameLayer.textItem.size = new UnitValue (fontSize, "px");

          while ((fontSize > 1) && (parseInt(nameLayer.bounds[2] - nameLayer.bounds[0]) >= maxWidth))

          {  

             fontSize -= 1;

             nameLayer.textItem.size  = new UnitValue (fontSize, "px");

          }

          • 2. Re: Resize font to fill text box
            c.pfaffenbichler Level 9

            At a quick glance that code should not do what you intend in that it would make all the text content the same font size.

            Scripting Type Layers that contain text with any variability (different fonts, sizes, leading, …) is not very convenient in my opinion.

            • 3. Re: Resize font to fill text box
              Apod42 Level 1

              Thanks for the feedback! For the moment I will continue to do this manually, maybe in the future will find a scripting solution or plugin...