Skip to main content
November 12, 2011
Question

photoshop text overflow

  • November 12, 2011
  • 1 reply
  • 7071 views

Hello,

Can someon help me with an issue i have. I have a text box in photoshop which i am putting varible data in, I cant stop the ext from overflowing. Can anyone help me with a script that if the text overflows it scales down. either by font or by scaling horizontaly or vertcally.

Thanks

This topic has been closed for replies.

1 reply

c.pfaffenbichler
Community Expert
Community Expert
November 15, 2011

I’m not optimistic for this task.

After all Photoshop is not really a page layout program and has somewhat limited type-spedific features.

And I could not identify a marker for overflow in the ActionDescriptor-code (though admittedly I only browsed it). 

You might be better off using BridgeTalk to do the typework in Indesign or Illustrator.

Maybe/probably someone else has more insight than me, though; you could also post on http://www.ps-scripts.com/

c.pfaffenbichler
Community Expert
Community Expert
November 15, 2011

One hardly practicable workaround might be to create a workPath from the text (Layer > Type > Create Work Path), then assess the number of subPathItems and if they are fewer than the text-string’s length minus the spaces the text probably overflows.

Inspiring
November 15, 2011

I also don't see any direct way to determine overflow text from looking at the layer descriptor. However instead of converting the text to a path and trying to work out the size I would get the current layer bounds, increase the size of the text bounding box and check the layer bounds again. If the bounds change the text was overflowed.

var currentBounds = app.activeDocument.activeLayer.bounds;

var currentBottom = currentBounds[3];

var currentTextBoxHeight = app.activeDocument.activeLayer.textItem.height;

app.activeDocument.activeLayer.textItem.height = app.activeDocument.activeLayer.textItem.height + new UnitValue(1200,'px');

var newBounds = app.activeDocument.activeLayer.bounds;

if( newBounds[3] != currentBottom ) alert('The layer has overflowed text');

app.activeDocument.activeLayer.textItem.height = currentTextBoxHeight;

Then you can deal with the overflow by changing the text properties, the text box, or converting to point type depending on which method fits your document best.