Fork me on GitHub
View source

package haxepunk.graphics.text

class Text


extends Image

Used for drawing text using embedded fonts.

Constructor

View source

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

Text 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 TextOptions font Font family. size Font size. align Alignment (one of: TextFormatAlign.LEFT, TextFormatAlign.CENTER, TextFormatAlign.RIGHT, TextFormatAlign.JUSTIFY). wordWrap Automatic word wrapping. resizable If the text field can automatically resize if its contents grow. color Text color. leading Vertical space between lines. richText If the text field uses a rich text string

Variables

align : TextAlignType

Font alignment.

font : String

Font family.

leading : Int

Leading (amount of vertical space between lines).

resizable : Bool

If the text field can automatically resize if its contents grow.

richText : String

Rich-text string with markup.

Use Text.addStyle to control the appearance of marked-up text.

size : Int

Font size.

text : String

Text string.

read only textHeight : Int

Height of the text within the image.

read only textWidth : Int

Width of the text within the image.

wordWrap : Bool

Automatic word wrapping.

Functions

View source

addStyle (tagName : String, params : StyleType) : Void

Add a style for a subset of the text, for use with the richText property.

Usage:

text.addStyle("red", {color: 0xFF0000});
text.addStyle("big", {size: text.size * 2, bold: true});
text.richText = "<big>Hello</big> <red>world</red>";
View source

getTextProperty (name : String) : Dynamic

Gets the specified property, by also inspecting the underlying TextField and TextFormat objects. Returns null if the property doesn't exist.

View source

render (point : Vector2, camera : Camera) : Void

View source

resize (width : Int, height : Int, redraw : Bool = true) : Void

View source

setBorder (style : BorderStyle = BorderStyle.FastOutline, size : Int = 1, color : Color = Color.Black, alpha : Float = 1) : Void

View source

setTextProperty (name : String, value : Dynamic) : Bool

Sets the specified property, by also inspecting the underlying TextField and TextFormat objects. Returns true if the property has been found and set, false otherwise.

View source

updateTextBuffer () : Void

@private Updates the drawing buffer.