Quicktip #6: fixing the cut off character on embedded-font-textfields

Posted by Bart Claessens on January 07, 2010
ActionScript 3, Flash, Flex, QuickTips

As we all know, Flash has these crazy bugs nobody ever understands. One of those is the fact that the last character of a dynamic textfield (which has been set to “AutoSize”) gets cut off when you’re using an embedded font. Up till now I still don’t understand what kind of situation leads to this exceptional behavior. The only thing I can say is that Flash Player fails to determine the correct text length which screws up the textfield width to be shorter than it has to be.

Example:

Blurred/Cut Off Characters

Blurred/Cut Off Characters





A quicktip post wouldn’t be a quicktip post without a solution. So, here’s one of the tricks you might give a go: increase the rightMargin property of the TextField to a small value like 1 or 2.

var textFormat:TextFormat = new TextFormat();
textFormat.rightMargin = 1;	
 
textField.antiAliasType = AntiAliasType.ADVANCED;
textField.gridFitType = GridFitType.SUBPIXEL;
textField.embedFonts = true;			
textField.autoSize = TextFieldAutoSize.CENTER;
textField.defaultTextFormat = textFormat;
textField.setTextFormat(textFormat);

Hope this helps!

  • Share/Bookmark

Tags: , , ,

1 Comment to Quicktip #6: fixing the cut off character on embedded-font-textfields

Ciro Continisio
March 4, 2010

You made my day (actually, night). Thanks!!

Leave a comment

WP_Big_City