Automatically resizing overset text in a text frame

Community Beginner ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

Hello,

During the data merge some on some of pages the title text frame has overset text (some titles are long). Is there any method (probably script) that would go through only those frames and resize the text (by setting font size/type)? Making frame auto size is not possible in this case

Best

Moni

TOPICS
How to , Scripting

Views

118

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , May 10, 2022 May 10, 2022
Scripting is the more elegant solution. Rudimentarily:  var d = app.activeDocument; var allTfs = d.textFrames; for (var i = 0; i < allTfs.length; i++) { while(allTfs[i].overflows) { allTfs[i].parentStory.pointSize -= .1; d.recompose(); } } Of course, you may want to implement a min point size threshhold, and this would shrink all text frames that contain overset text. This would also not find text frames grouped or otherwise imbedded in other frames; you'd use all...

Likes

Translate

Translate
Advocate ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

Use GREP style in your paragraph styles to change the size of the text.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

But how? In GREP there is no property denoting that text is overset?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

You need to figure out approximately how many characters fit in your text box width/length and create GREP style that reduce the text starting at this number. It might be enough for you. But without seen the complexity of your file it a guess on my part.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

Ok, I undestand the concept, will try that. Thank you for the idea.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

Hi Moni,

without writing a script:

Apply a GREP Style to the paragraph style that is applied to the text of that titles.

The GREP pattern will "count" the number of characters and applies a character style with a smaller point size to the text if a certain threshold or number of characters in the paragraph is detected:

 

GREP Style pattern suggestion for a case with 24 characters or more:

(?=.{24,}$)^.+

Apply a character style that is set to a smaller point size with auto leading.

You could also do a cascade of GREP Styles like the one above for other amounts of characters. See my screenshot below. In all four text frames the same paragraph style is applied. Depending on the number of characters in the paragraph a different character style with a different text size is effective:

 

SmallerText-GREPStyles-CharCount-1.PNG

 

Note: In the solution above I assume that your headlines consist of one paragraph only.

 

Regards,
Uwe Laubender

( ACP )

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

Good method, thank you!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

Just to be sure, it counts only letters/numbers or all characters in a string? (I have things like commas, parenthesis, semicolons, etc in titles)

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

No. It will count everthing spaces included.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

LATEST

Scripting is the more elegant solution. Rudimentarily: 

 

var d = app.activeDocument;
var allTfs = d.textFrames;
for (var i = 0; i < allTfs.length; i++) { 
    while(allTfs[i].overflows) { 
        allTfs[i].parentStory.pointSize -= .1; 
        d.recompose();
    } 
}

 

Of course, you may want to implement a min point size threshhold, and this would shrink all text frames that contain overset text. This would also not find text frames grouped or otherwise imbedded in other frames; you'd use allPageItems for that. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines