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

Change font size dynamically based on character count

New Here ,
Apr 22, 2019 Apr 22, 2019

Context: I have very basic experience with JavaScript. I mainly know HTML/CSS well.

Let's say I want to fill 1,000 pages with 1,000 phrases. One phrase per page, and the text has to fill the maximum amount of space in the page.

So I think I would need something like this: If "Hello there" is 60pt to fill the page, but the next page contains "How are you?" dynamically change the font size to fit the page (like 40pt). Am I on the right track or should I do something else?

I understand this may have something to do with strings and character counts. I have found some clues in JavaScript but also need help changing some of the language to work in InDesign.

jquery - Change Font Size dynamically based on Character count - Stack Overflow

jquery - Auto-size dynamic text to fill fixed size container - Stack Overflow

TOPICS
Scripting
3.4K
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
New Here ,
Apr 23, 2019 Apr 23, 2019

In looking for a script to dynamically change text color, I found this:

Fun With Text Fitting in InDesign | in-tools.com

It's a link to a script and directions to fit text within a given frame size (in your example, the frame size could be the whole page).

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 ,
Apr 23, 2019 Apr 23, 2019

Character count is not a useful way to fit text in a frame. You can change the type size in small steps until the text fits the frame. Or better yet, check Marc Autret's site, he had a function (which I think he also showed in this forum), which uses a more sophisticated method to fit text to a frame. I don't have a link to that specific function -- Marc's site is at www.indiscripts.com.

P.

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 ,
Apr 23, 2019 Apr 23, 2019

Hi Peter,

I think this is the article:

Indiscripts :: On Dichotomic Divide-and-Conquer Algorithms

Regards,
Uwe

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 ,
Apr 23, 2019 Apr 23, 2019

Yes, Uw, that's the one. Thanks for posting the link.

P.

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 ,
Apr 23, 2019 Apr 23, 2019

Though it's about resizing the frame, not the type size, the method would be comparable. (Can't edit messages for some reason.)

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 ,
Apr 24, 2019 Apr 24, 2019
LATEST

Hi Peter,

one link in the article is leading to this discussion:

Overflows property update process

Regards,
Uwe

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