A basic text renderer with multiline support.
See Text section of the manual for more details.
Constructor
new(font:Font, ?parent:Object)
Creates a new Text instance.
Parameters:
font | The font used to render the Text. |
---|---|
parent | An optional parent |
Variables
dropShadow:{dy:Float, dx:Float, color:Int, alpha:Float}
Adds simple drop shadow to the Text with specified offset, color and alpha. Causes text to be rendered twice (first drop shadow and then the text itself).
maxWidth:Null<Float>
When set, limits maximum line width and causes word-wrap.
Affects positioning of the text depending on textAlign
value.
When Text is affected by size constraints (see Object.constraintSize
), smallest of the two is used for word-wrap.
textAlign:Align
Text align rules dictate how the text lines are positioned.
See Align
for specific details on each alignment mode.
read onlytextHeight:Float
Calculated text height.
Not a completely precise text metric and increments in the Font.lineHeight
steps.
In HtmlText
, can be increased by various values depending on the active line font and HtmlText.lineHeightMode
value.
Methods
calcTextWidth(text:String):Float
Calculates and returns width of the provided text
with settings this Text instance.
getTextProgress(text:String, progress:Float):String
Returns cut text
based on progress
percentile.
Can be used to gradually show appearing text. (Especially useful when using HtmlText
)
privatesplitRawText(text:String, leftMargin:Float = 0., afterData:Float = 0., ?font:Font, ?sizes:Array<Float>, prevChar:Int = -1):String
Parameters:
text | String to word-wrap. |
---|---|
leftMargin | Starting x offset of the first line. |
afterData | Minimum remaining space required at the end of the line. |
font | Optional overriding font to use instead of currently set. |
sizes | Optional line width array. Will be populated with sizes of split lines if present. Sizes will include both |
prevChar | Optional character code for concatenation purposes (proper kernings). |
privatevalidateText():Void
Extra validation of the text
variable when it's changed. Override to add custom validation.
Only validation of the text is allowed, and attempting to change the text value will lead to undefined behavior.