What is up with FormattedHeight?

Ken Corey ken at kencorey.com
Thu Feb 9 04:15:25 EST 2012


On 06/02/2012 03:30, Howard Bornstein wrote:
> I need to find the smallest rectangle that will enclose a line of text of
> arbitrary text size in a field. I thought I could use formattedheight and
> formattedwidth to do this but it doesn't seem to be working.

I'm very perplexed too.

Instead of worrying about what is/is not added to the text image, fonts, 
screen smoothing, margins, whatever (itis bound to have a 
platform-specific element to it), I figured "Why not just ask the bits?"

So, I wrote a script (http://its.ec/static/testfield.livecode.zip) to 
investigate.

It takes a snapshot of the field and puts it into a new image.  Step 
through the bits of that image, and we should be able to say exactly 
where the text begins and ends, right?

Only...it doesn't work as I've written it.  No pixels are found.

Ah, okay, maybe I didn't understand something, so I added a graphic from 
a PNG, and did the search on that, and it finds the pixels very easily.

Same code, only the name has been changed.  Different result.

Clearly, there's something I don't understand at work here.

Can anyone see what I've done wrong (and help Howard too?)

On the plus side, it does this /very/ quickly.  I was surprised at how 
fast stepping through the pixels of the graphic in a loop actually is.

-Ken




More information about the use-livecode mailing list