This content has been marked as final. Show 11 replies
I've encountered difficulties using getTextExtent before (as2) .
I remember that even in some of the v2 components there are some workarounds for it, here's something about it:
I just hunted around to find what I did last time I encountered it. Its surrounded by a lot of kludge.
I ended up doing some ugly looping with font sizes in TextFormat and then repeatedly checking the textfield's textHeight property for what I was trying to achieve. I had tried with getTextExtent and couldn't get it to work. It was with an embedded font also.
Maybe I was doing something wrong to start with but I gave up after I did a bit of research that gave me reason to believe I was not going to have much luck with getTextExtent.
Interesting. The other times I've used it were for when the user would have the font installed on their machine – an case where getTextExtent seems to work just fine.
So I like the approach they used in the UIObjectExtensions patch. I was starting to formulate that in my head as a possible work around and will give that a try for my project.
Now how do we report this as a bug and get a ticket opened? :)
Just occurred to me that the problem could be with how Flash is embedding the font? And that getTextExtent() works just fine, but rather the metrics for the embedded font are messed up?
....Maybe, but take a look in UIObjectExtensions.as and use find 'getTextExtent2'
That's what I was trying to remember...
Yeah I took a peek. That is what I meant by "I was starting to formulate…" I had started thinking along those lines, I just hadn't started to code it up.
Sorry - just to clarify:
UIObjectExtensions.as is in mx.core.ext
Oops too late. you already found it. So... that's why I gave up when I was trying to do it. If Macromedia thought it was broken that was good enough for me to be convinced. lol
Oops again.. I just scrolled up and saw your earlier comment that you'd already found it... its 1;30am where I am.. I'm way too tired... I'm going to bed. Good luck with it..
Thanks for all your help.
And yes, it is broken, but I'm the type of person who really wonders "why" and "exactly how" it is broken. Just the way I am. To me it is quite interesting the possibility that getTextExtent works totally fine, but that the process of embedding fonts has some issues – actually seems quite likely to me!
Anyways, thanks again and get some sleep!
After some testing the problem seems to go away if I use a font that I've put in my library. To me it is looking more and more like there is something wrong with the way fonts are embedded from the properties panel!
Well, I'd be keen to know the definitive answer. I can't remember what I was using last time... I don't often do the embedding just in an individual textfield, and mostly use the library too. I wonder whether it could have been because the advanced textrenderer was introduced in version 8 for embedded fonts. I don't know if that affects text placement because of 'size' changes or just appearance from predetermined placement. If it affects placement then maybe the gridfitType setting or the other advanced settings weren't taken into account.
From a couple of recent comments and a quick peek at the as3 version the metrics information is obtained in a different way. I assume (hope?) it's accurate for as3.