Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Automatically resizing overset text in a text frame

Community Beginner ,
May 10, 2022 May 10, 2022

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
1.1K
Translate
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

Community Expert , 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

...
Translate
Community Expert ,
May 10, 2022 May 10, 2022

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

Translate
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

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

Translate
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 Expert ,
May 10, 2022 May 10, 2022

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.

Translate
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

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

Translate
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 Expert ,
May 10, 2022 May 10, 2022

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.PNGexpand image

 

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

 

Regards,
Uwe Laubender

( ACP )

 

Translate
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

Good method, thank you!

Translate
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

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)

Translate
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 Expert ,
May 10, 2022 May 10, 2022

No. It will count everthing spaces included.

Translate
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 Expert ,
May 10, 2022 May 10, 2022
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. 

Translate
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