Article written

  • on 31.08.2009
  • at 12:12 PM
  • by mich

Problem with TextField.textWidth/TextField.width 2

Aug31

The problem:

Recently I struggled over another problem with the TextField where the textWidth / width was not calculated right.

Picture

On the screenshot you can see textfields stacked from the left to the right corresponding to the width of the textfield. If you look closely to the borders you see that the leading and tailing spaces around the words are not equal at all. Especially at the word “Newsletter” the tailing space too small. The texfield was setup like this;

label.autoSize = TextFieldAutoSize.LEFT;
label.wordWrap = false;
label.multiline = false;
label.antiAliasType = AntiAliasType.ADVANCED;
label.gridFitType = GridFitType.PIXEL;
label.embedFonts = true;
label.border = true;
var test:TextFormat = new TextFormat();
test.kerning = true;
test.font = "Futura";
label.setTextFormat( test );

The solution:

It seems that this is a flash bug and you can get over this by changing the GridFitType.PIXEL to GridFitType.SUBPIXEL.
The resulting textfields look like this;

Picture 1

subscribe to comments RSS

There are 2 comments for this post

  1. jeroen van vaerenbergh says:

    Thanks a lot. You fixed my problem.

  2. guchkogleb says:

    Dear Author http://www.indieas.org !
    Certainly. I join told all above.

Please, feel free to post your own comment

* these are required fields

Developed by Dariusz Siedlecki and brought to you by FreebiesDock.com