AS3 TextField AntiAliasType breaks WordWrap

2019-06-14 10:36发布

问题:

I am dynamically creating and populating a TextField in AS3. I have embedded some fonts into my library (using Flash) and am setting the font of the text field using TextFormat. Because of the limited width of the TextField I have textfield.multiline = true; and textfield.wordWrap = true;, however I have noticed that the fonts look a little pixelated.

To fix this I am using textfield.antiAliasType = AntiAliasType.ADVANCED; which makes the text look nice, but stops the word-wrap from working. In fact it looks quite odd; The text keeps keeps going off the width of the TextField then puts the last word on a new line.

What do I need to do to make it look good and wrap?

回答1:

Typical. Ask a question, find the answer =/

Specifying a grid fit type to the TextField fixes it. Don't know why:

textfield.gridFitType = GridFitType.SUBPIXEL;

From the documentation:

Fits strong horizontal and vertical lines to the sub-pixel grid on LCD monitors. (Red, green, and blue are actual pixels on an LCD screen.) This is often a good setting for right-aligned or center-aligned dynamic text, and it is sometimes a useful tradeoff for animation vs. text quality. This constant is used in setting the gridFitType property of the TextField class. Use the syntax GridFitType.SUBPIXEL.