An object for drawing text using a bitmap font.
Available since:
2.5.0
Static functions
static defineCustomTag (tag : String, func : CustomRenderFunction) : Void
Define a custom text rendering tag. Custom tags include a function which takes the BitmapText and a RenderData object as parameters, and are called before a glyph or image are rendered. Any modifications to the RenderData object will be reflected in the rendered text; however, note that you shouldn't hold onto the object reference, as it may be reused.
Parameters:
tag | The tag name, e.g. "shake" (used as " | |
func | The CustomRenderFunction |
Available since:
4.0.0
static defineFormatTag (tag : String, options : FormatTagOptions) : Void
Define a new format tag which can be used to modify the formatting of a subset of text.
Parameters:
tag | The tag name, e.g. "red" (used as " | |
options | Formatting options for this tag. |
Available since:
4.0.0
static defineImageTag (tag : String, image : Image, padding : Int = 0) : Void
Define a markup tag which can be used to render an Image. Should be used as a self-closed tag.
Parameters:
tag | The tag name, e.g. "my-img" (used as " | |
image | An Image to be rendered. The Image's coordinates, origin, angle and scale can be modified. |
Available since:
4.0.0
Constructor
new (text : Utf8String, x : Float = 0, y : Float = 0, width : Int = 0, height : Int = 0, options : BitmapTextOptions) : Void
BitmapText constructor.
Parameters:
text | Text to display. | |
x | X offset. | |
y | Y offset. | |
width | Image width (leave as 0 to size to the starting text string). | |
height | Image height (leave as 0 to size to the starting text string). | |
options | 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.) |
Variables
read only charCount : Int
The total number of visible characters (or images) in the text.
displayCharCount
can be between 0 and this number.
charSpacing : Int
displayCharCount : Int
How many characters of text to render. If -1, render the entire string; if less than the number of visible characters, will end early. Images and line breaks count as one character each.
height : Int
lineSpacing : Int
scale : Float
scaleX : Float
scaleY : Float
textHeight : Int
textWidth : Int
width : Int
wrap : Bool