AttributedText
Text with styles.
Module | require("gui") |
Type | Class |
On Windows, due to the limitations of GdiPlus, it is only supported to change
the whole text's color and font, i.e. the SetFontFor
and SetColorFor
APIs
are unsupported.
Class methods
create(text, attributes)
Create an AttributedText
.
Parameters
String
textTextAttributes
attributes
Return
AttributedText
Methods
setFormat(format)
Overwrite styles with format
.
Parameters
TextFormat
format
getFormat()
Return current styles.
Return
TextFormat
setFont(font)
Set the whole text's font
.
Parameters
Font
font
macOS Linux
setFontFor(font, start, end)Set the font
of text between character range [start, end)
. Passing
-1
as end
means the rest of the text.
Parameters
Font
fontInteger
startInteger
end
setColor(color)
Set the whole text's color
.
Parameters
Color
color
macOS Linux
setColorFor(font, start, end)Set the color
of text between character range [start, end)
. Passing
-1
as end
means the rest of the text.
Parameters
Color
fontInteger
startInteger
end
clear()
Reset font and color to system default.
getBoundsFor(size)
Return the bounds required to draw the text within size
.
Parameters
SizeF
size
Return
RectF
setText(text)
Change the text content.
Parameters
String
text
getText()
Return the plain text.
Return
String