1

I need to display antialiased systemfonts (because the swf filesize must be small, therefore i can't embedd fonts). So I wrote this script in order to manually antialias the text

Code:

    public function renderTextField():BitmapData{
        var w:int = this["mainTextField"].textWidth+10;
        var h:int = this["mainTextField"].textHeight+10;
        var bitmapData:BitmapData = new BitmapData(w*3,h*3,false,0x000000);
        var antialiased:BitmapData = new BitmapData(w,h,false,0x000000);
        var transf:Matrix = new Matrix();
        transf.scale(3,3);
        bitmapData.draw(this["mainTextField"],transf);
        var bitmap:Bitmap = new Bitmap(bitmapData,"auto",true);
        transf = new Matrix();
        transf.scale(1.0/3.0,1.0/3.0);
        antialiased.draw(bitmap,transf,null,null,null,true);
        return antialiased;
    }

this works pretty well, but there's a nasty thing. Sometimes the scaling of the draw call affects the texts formatting. for example, the last word of a line will be the first word of the next line instead. This must not happen! does anyone have an idea why it happens and how i can avoid it? i want the text to be rendered into the bitmapData exactly as it appears in the textbox

thanks!

genesys
  • 41
  • 2
  • 5

2 Answers2

0

Take a look at the new text engine (requires Player 10.0, out for more than one year): http://labs.adobe.com/technologies/textlayout/

Mihai Nita
  • 5,547
  • 27
  • 27
0

Apparently, when a TextField is scaled up, it's not scaled the same way that a vector drawing would be. The TextField's bounding area is scaled up, but the actual text contents has its font size increased to fill that new area instead, which can cause the vertical alignment to shift slightly and/or push words to the next line.

BladePoint
  • 632
  • 5
  • 16