4 Replies Latest reply on Dec 23, 2009 3:05 PM by doug-grio

    Setting the font of a UITextField control


      I am using a UITextField control to create text offscreen, then I'm using ImageSnapshot to get a bitmap and draw it on the screen using graphics methods. It's working fine, except for one thing: for the life of me I cannot change the font used from Times Roman.


      I've scoured the internet and tried many things, such as using a style (stylename=, not setStyle), trying the setTextFormat function, but nothing works.


      I have a work-around using a label control that is part of the parent container with visible=false, but it is not correctly autosizing as I'd like and there are other issues that crop up in this approach.


      Does anyone know how to how to set the font and get it to be used? Here is a snippet of code:


                          var sizeText : UITextField = new UITextField();
                          sizeText.autoSize = TextFieldAutoSize.LEFT;
                          sizeText.background = true;
                          var textFormat : TextFormat = new TextFormat( "Arial", 13, 0xAAAAAA );
                          sizeText.setTextFormat( textFormat );
                          sizeText.text = "blah";

                          var textBitmapData:BitmapData = ImageSnapshot.captureBitmapData( sizeText );


                          var coef:Number = Math.min( sizeText.measuredWidth / textBitmapData.width, sizeText.measuredHeight / textBitmapData.height );
                          sizeMatrix = new Matrix(coef, 0, 0, coef);
                          textBitmapData = ImageSnapshot.captureBitmapData( sizeText, sizeMatrix );


      Thx in advance, d.