Skip to main content
Inspiring
January 12, 2016
Question

Identify overset text in a text frame

  • January 12, 2016
  • 1 reply
  • 1123 views

Hi

I have some text frames in a document. Some of these text frames has more text than it could display (so a portion of the text is hidden).

Is there any way (a property or method) JavaScript could know a text frame has overset text?

For example. To test, suppose I want to test a specific layer called "phrase". So:

var doc = app.activeDocument

var phrase = doc.layers.getByName("phrase");

if (<CONDITION TO KNOW IF PHRASE HAS OVERSET>){

//treat the problem

}

Any suggestion?

Looked at Photoshop JavaScript reference but did not found any property or method for layer.textItem to return such information.

Thank you very much

Gustavo

This topic has been closed for replies.

1 reply

JJMack
Community Expert
Community Expert
January 12, 2016

I believe you referring to text layers not frames.  I would think that you could write a script that could check all text layers in a document. Check that the bounds of a text layer lie within the bounds of the documents canvas.  Other check could also be made to check it any of the layer in the layer stack above the text layer is visible and may be hiding  part or all of the text layer.

JJMack
Inspiring
January 12, 2016

Hi JJMack

Yes I'm referring to text layers (text frames are in Illustrator hehehe). But not sure if your suggestions suits my need. Let's show an example:

Look at this PSD file: https://dl.dropboxusercontent.com/u/35273119/Test.psd

It has only one layer, a text layer called "Phrase". If you evaluate in Photoshop you will perceive this text box has more text than the box could display (so, there's overset text). You could increase the box or reduze the font size to see the entire text.

I want the script to evaluate if a text layer has overset text, because, if it has, I´ll pass the respective layer to a function correct and display all the text.

I know how to create this function and also check if a kind of a layer is text. But I did not find any property or method in JavaScript to return telling me if the text layer has or no overset.

Any idea?

Thank you very much

Gustavo

JJMack
Community Expert
Community Expert
January 12, 2016

I see now you writing about paragraph text where there was more text then fits into the text paragraph bounding box for the font size in use. That you want to reduce the font size using a script.  I don't use text that much and have not scripted using text much.  Text is is very complex particularly when font have various width characters and support all sorts of  character spacing.   I do not know if the is a way to text to see if the text you have the with the current font size and character spacing if it will overflow a paragraph area space.  There have been many treads on changing test and getting text attributes in threads here.  I do not know if your topic has been addresses. Try searching this forum.

https://forums.adobe.com/search.jspa?place=%2Fplaces%2F1383833&q=text%2Coverflow

JJMack