[CLASS] Proof of concept: Antialias in TextFields

Continuing the discussion from Antialiasing/smoothing problem on text and images:

I’ve been thinking about this today and in the end I tried to draw a TextField on a Bitmap and then apply the affine transformation on that Bitmap.

The result is good and if not as perfect as in Flash it is anyway better than normal antialias.
So I wrapped the idea in the TextFieldSmooth class.
This class is a TextField in Flash (it is actually a 100% TextField on that target), because Flash renders fonts beautifully;
in other targets it is a Bitmap (with the .text property linked directly to the textfield).

This is a proof of concept, it should be expanded to expose in a consistent way all the other properties of a TextField, but I am happy because it works and it will be useful for a project I am developing.

After I’ve finished this I’ve come across the HaxeFlixel source code, and tadahhh: they manage the smoothing process on fonts in the exact same way.
Since my class let Flash use directly a TextField, it actually looks better on that target. In any other case, it is “the same” as HaxeFlixel.

So my idea was not too bad.

Here is a picture that show you the effect (zoom to see the details):

If the text is quite small the difference is easier to see :smile:

Here is the source code and example
https://dl.dropboxusercontent.com/u/683344/akifox/openflcommunity/TextFieldSmooth.zip

Here you can see the class source code in github (this repository is a work in progress, quite messy right now, ignore the context)
https://github.com/yupswing/akifox-lib/blob/master/com/akifox/lib/gui/TextFieldSmooth.hx

Cheers
yup

1 Like