Fit text in a field

J. Landman Gay jacque at hyperactivesw.com
Tue Nov 4 13:34:27 EST 2014


On 11/4/2014, 8:01 AM, Pyyhtiä Christer wrote:
> Is there a known way of fitting a specific (variable from case to
> case) text string into a field with a definition of the font and
> min&max text size? The other parameter would be wrap/no-wrap to tell
> you want just a one-liner. For multi-liner, anyone been coding in
> hyphenation algorithm (for English) in LC?

Basically you have to just brute-force your way through it one test at a 
time. Set the templateField to the font and wrap settings as needed. Put 
the text into it and check the formattedwidth and formattedheight. If 
it's bigger than the max or smaller than the min, adjust the text size 
and try it again. Lock messages to make it a little faster.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com





More information about the use-livecode mailing list