AttributedText
Text with styles.
| Module | require("yue.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
stringtextTextAttributesattributes
Return
AttributedTextMethods
setformat(format)
Overwrite styles with format.
Parameters
TextFormatformat
getformat()
Return current styles.
Return
TextFormatsetfont(font)
Set the whole text's font.
Parameters
Fontfont
setfontfor(font, start, end) macOS Linux
Set the font of text between character range [start, end). Passing
-1 as end means the rest of the text.
Parameters
Fontfontintegerstartintegerend
setcolor(color)
Set the whole text's color.
Parameters
Colorcolor
setcolorfor(font, start, end) macOS Linux
Set the color of text between character range [start, end). Passing
-1 as end means the rest of the text.
Parameters
Colorfontintegerstartintegerend
clear()
Reset font and color to system default.
getboundsfor(size)
Return the bounds required to draw the text within size.
Parameters
SizeFsize
Return
RectFsettext(text)
Change the text content.
Parameters
stringtext
gettext()
Return the plain text.
Return
string