             var textField:TextField     = new TextField();
             textField.autoSize          = TextFieldAutoSize.LEFT;
             textField.defaultTextFormat = textFormat;
+            textField.antiAliasType     = AntiAliasType.ADVANCED;
             textField.text              = text.replace(/[\t\n\f\r]/g, " ");
             textField.setTextFormat(textFormat);
             return {width: textField.textWidth + 4, height: textField.textHeight + 4 };


            // Remove 2px margins around the text
            var matrix:Matrix = new Matrix();
//            matrix.translate(-2, -2);

            if (isStroke)
            {


            // Convert the text into BitmapData
            var bitmapData:BitmapData = new BitmapData(width + 4, height + 4, true, 0);
            bitmapData.draw(textField, matrix, null, null, null, true);

            // Adjust x coordinates
            switch (state.textAlign)
