Locking for an idea to ....

Sarah Reichelt sarah.reichelt at gmail.com
Mon Feb 22 16:41:48 EST 2010


On Mon, Feb 22, 2010 at 9:42 PM, Rolf Kocherhans
<rolf.kocherhans at id.uzh.ch> wrote:
> Hello all
>
> I am looking for an idea to the following problem :-)
>
>
> I have a non focused label text field of a fixed length, I use it
> to display e.g. email adresses.
>
> Sometimes the email address fits into the field, but other
> times the email address ist to long, so I only see 80% of it.
>
> I now noticed that the iPhones address application,
> automatically reduces the font size to be able to always
> display the whole address.


Here is the routine I use:

            -- shrink font until it fits, down to a minimum of 8
            set the textSize of fld tFieldName to 12
            put 12 into tStartSize
            repeat 4 times
                if the formattedWidth of fld tFieldName > the width of
fld tFieldName then
                    subtract 1 from tStartSize
                    set the textSize of fld tFieldName to tStartSize
                else
                    exit repeat
                end if
            end repeat
            show fld tFieldName

If the font gets to size 8 and the text is still not all fitting into
the field, then maybe you need to truncate it.

Cheers,
Sarah



More information about the use-livecode mailing list