Fork me on GitHub
View source


class BitmapText

extends Graphic

An object for drawing text using a bitmap font.

Available since:



View source

new (text : String, x : Float = 0, y : Float = 0, width : Float = 0, height : Float = 0, options : BitmapTextOptions) : Void

BitmapText constructor.


Text to display.


X offset.


Y offset.


Image width (leave as 0 to size to the starting text string).


Image height (leave as 0 to size to the starting text string).


An object containing optional parameters contained in BitmapTextOptions font Name of the font asset (.fnt or .png). size Font size. format Font format (BitmapFontFormat.XML or BitmapFontFormat.XNA). wordWrap Automatic word wrapping. color Text color. align Alignment ("left", "center" or "right"). (Currently ignored.) resizable If the text field can automatically resize if its contents grow. (Currently ignored.) leading Vertical space between lines. (Currently ignored.) richText If the text field uses a rich text string. (Currently ignored.)


alpha : Float

autoHeight : Bool

Whether or not to automatically figure out the height and width of the text.

default value


autoWidth : Bool

charSpacing : Int

color : Int

height : Float

lineSpacing : Int

lines : Array<String>

scale : Float

scaleX : Float

scaleY : Float

size : Int

smooth : Bool

Default value: false if HXP.stage.quality is LOW, true otherwise.

text : String

textHeight : Int

textWidth : Int

width : Float

wrap : Bool


View source

computeTextSize () : Void

Run through the render loop without actually drawing anything. This will compute the textWidth and textHeight attributes.

View source

updateBuffer (oldLines : Array<String>) : Void

Update the drawing buffer on software rendering mode. For efficiency, if any lines were unchanged from previously rendered text, they will not be re-drawn.

View source

wordWrap () : Void

Automatically wraps text by figuring out how many words can fit on a single line, and splitting the remainder onto a new line.