Skip to main content
Participant
January 31, 2011
Question

Automating font size for TextFlow

  • January 31, 2011
  • 1 reply
  • 382 views

I want to render a short one-line text in a container width a static width, where the font size is automatically decreased if the string is to long.

Is there a smarter way to do this besides starting with a large font size and decreasing it in a loop until the text fits in, like it's done here

This topic has been closed for replies.

1 reply

Adobe Employee
January 31, 2011

No, I think you need to iteratively change the size and measure the text until it fits.

One thing I would suggest rather than starting large and uniformly decreasing is to try a binary search of different sizes until you've found the one that is slightly smaller than the measure, and the one that is slightly bigger. Decreasing steadily will certainly work, but it will likely take more iterations and therefore more time.

- robin