A simple HTML text renderer.
See the Text section of the manual for more details and a list of the supported HTML tags.
Static methods
staticdynamicdefaultFormatText(text:String):String
A default method HtmlText uses to format assigned text. See HtmlText.formatText
for details.
staticdynamicdefaultLoadFont(name:String):Font
A default method HtmlText uses to load fonts for <font>
tags with face
attribute. See HtmlText.loadFont
for details.
staticdynamicdefaultLoadImage(url:String):Tile
A default method HtmlText uses to load images for <img>
tag. See HtmlText.loadImage
for details.
staticdefineDefaultHtmlTag(name:String, ?fontColor:Int, ?fontName:String):Void
Associate a custom html tag to a specific font and color.
Constructor
Variables
condenseWhite:Bool = true
When enabled, condenses extra spaces (carriage-return, line-feed, tabulation and space character) to one space. If not set, uncondensed whitespace is left as is, as well as line-breaks.
imageVerticalAlign:ImageVerticalAlign = Bottom
Vertical alignment of the images in <img>
tag relative to the text.
lineHeightMode:LineHeightMode = Accurate
Line height calculation mode controls how much space lines take up vertically.
Changing mode to Constant
restores the legacy behavior of HtmlText.
propagateInteractiveNode:Bool = false
When enabled, nodes that create interactives will propagate events
Methods
defineHtmlTag(name:String, ?fontColor:Int, ?fontName:String):Void
Define a custom html tag to be displayed with specific font and color.
defineHtmlTags(tags:Array<{name:String, font:Null<String>, color:Null<Int>}>):Void
Define or reset a set of custom html tags to be displayed with specific font and color.
dynamicformatText(text:String):String
Called when text is assigned, allowing to process arbitrary text to a valid XHTML.
dynamicloadFont(name:String):Font
Method that should return an h2d.Font
instance for <font>
tags with face
attribute. By default calls HtmlText.defaultLoadFont
method.
HtmlText does not cache font instances and it's recommended to perform said caching from outside.
Due to internal structure, method should be deterministic and always return same Font instance on consequent calls with same name
input.
Parameters:
name | A value contained in |
---|
Returns:
Method should return loaded font instance or null
. If null
is returned - currently active font is used.
dynamicloadImage(url:String):Tile
Method that should return an h2d.Tile
instance for <img>
tags. By default calls HtmlText.defaultLoadImage
method.
HtmlText does not cache tile instances.
Due to internal structure, method should be deterministic and always return same Tile on consequent calls with same url
input.
Parameters:
url | A value contained in |
---|