getTextExtent()
- Started
- Last post
- 7 Responses
- bry
damn you getTextExtent, you're like the kind of son i never had except when you wash the dishes for me you wash it with URINE.
so nobody yet has found a good workaround for getting reliably correct measurements for flash's getTextExtent??? and why hasn't macromedia worked on getting this right yet?
- SteveJobs0
their support for text fomatting is sub par. you know it, they know it everyone knows it. but then again, they don't have much competition do they.
- ********0
I've written getTextExtent2(), which is pretty accurate...
you know about Macs returning the value in twips instead of pixels right?
- ********0
Here's the prototype
TextFormat.prototype.getTextExte... = function(str){
var sysOs = System.capabilities.os;
var textExt = this.getTextExtent(str);
if(sysOs.toLowerCase().indexOf... != -1){
textExt.width /= 20;
textExt.height /= 20;
}
return textExt;
}
- SteveJobs0
getTextExtent2 - now that's well documented...
- ********0
no, i wrote it, it's just an prototype for the TextFormat class, use as if it were getTextExtent, it will return same values on PC, but on Mac will convert from Twips to Pixels...
Hope that helps
- SteveJobs0
haha, i know i meant to post that before you posted your code. didn't know about the twips tho...
- bry0
thanks for the mac tip. i remember reading about the twips/px issue but i nearly forgot about it.
however, i haven't even started testing for mac yet and getTextExtent still yields crappy values on PC.
i.e.: getTextExtent(text,[width]) : the resulting width value is grossly underestimated compared to the width value i feed it. shouldn't the resulting width be very close to if not exactly equal to the width value?
i'm just surprised not more people are crying foul over this feature (especially with the increasing advent of custom UI's that adapt to the amount of encased text )