Is it possible to get accurate character/font metrics in AS3?

1.2k views Asked by At

I have created a class which will use an embedded font to dynamically generate a bitmap font at run-time. So far it works well except that I have a minor issue with character spacing.

In the image below the first line is an actual TextField and the second has been rendered using the generated bitmap font.

Character spacing problem example

If you look at the word 'fox' or the 'ed' of the word 'jumped' you can see that the letter spacing looks a little bit odd.

Are there any alternatives to the TextLineMetrics class which will give me more accurate character metrics?

UPDATE :

Text rendering quality using the new Flash Text Engine :

Text rendering quality using the new Flash Text Engine

UPDATE 2 :

By chance I have eventually found the solution :

The first problem was the antiAliasType property which was set to AntiAliasType.ADVANCED.
Although it produces higher quality text it also causes TextLineMetrics to return incorrect widths for characters.

The second was that it had to also be rounded up (using Math.ceil) to the nearest pixel and not down.

1

There are 1 answers

1
Guan Yuxin On BEST ANSWER

TextField is too heavy to that. flash.text.engine will work better for bitmap generateing