Rich text can contain custom text, fonts, images and some basic formatting. The label manages these as an internal tag stack. It also adapts itself to given width/heights.
[b]Note:[/b] Assignments to [member bbcode_text] clear the tag stack and reconstruct it from the property's contents. Any edits made to [member bbcode_text] will erase previous edits made from other manual sources such as [method append_bbcode] and the [code]push_*[/code] / [method pop] methods.
[b]Note:[/b] RichTextLabel doesn't support entangled BBCode tags. For example, instead of using [code][b]bold[i]bold italic[/b]italic[/i][/code], use [code][b]bold[i]bold italic[/i][/b][i]italic[/i][/code].
[b]Note:[/b] Unlike [Label], RichTextLabel doesn't have a [i]property[/i] to horizontally align text to the center. Instead, enable [member bbcode_enabled] and surround the text in a [code][center][/code] tag as follows: [code][center]Example[/center][/code]. There is currently no built-in way to vertically align text either, but this can be emulated by relying on anchors/containers and the [member fit_content_height] property.
[b]Note:[/b] Unicode characters after [code]0xffff[/code] (such as most emoji) are [i]not[/i] supported on Windows. They will display as unknown characters instead. This will be resolved in Godot 4.0.
</description>
<tutorials>
<linktitle="BBCode in RichTextLabel">$DOCS_URL/tutorials/ui/bbcode_in_richtextlabel.html</link>
[b]Note:[/b] Using this method, you can't close a tag that was opened in a previous [method append_bbcode] call. This is done to improve performance, especially when updating large RichTextLabels since rebuilding the whole BBCode every time would be slower. If you absolutely need to close a tag in a future method call, append the [member bbcode_text] instead of using [method append_bbcode].
[b]Note:[/b] This method internals' can't possibly fail, but an error code is returned for backwards compatibility, which will always be [constant OK].
Returns the total number of characters from text tags. Does not include BBCodes.
</description>
</method>
<methodname="get_v_scroll">
<returntype="VScrollBar"/>
<description>
Returns the vertical scrollbar.
[b]Warning:[/b] This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their [member CanvasItem.visible] property.
The assignment version of [method append_bbcode]. Clears the tag stack and inserts the new content.
[b]Note:[/b] This method internals' can't possibly fail, but an error code is returned for backwards compatibility, which will always be [constant OK].
Adds an [code][align][/code] tag based on the given [code]align[/code] value. See [enum Align] for possible values.
</description>
</method>
<methodname="push_bold">
<returntype="void"/>
<description>
Adds a [code][font][/code] tag with a bold font to the tag stack. This is the same as adding a [code][b][/code] tag if not currently in a [code][i][/code] tag.
</description>
</method>
<methodname="push_bold_italics">
<returntype="void"/>
<description>
Adds a [code][font][/code] tag with a bold italics font to the tag stack.
</description>
</method>
<methodname="push_cell">
<returntype="void"/>
<description>
Adds a [code][cell][/code] tag to the tag stack. Must be inside a [code][table][/code] tag. See [method push_table] for details.
</description>
</method>
<methodname="push_color">
<returntype="void"/>
<argumentindex="0"name="color"type="Color"/>
<description>
Adds a [code][color][/code] tag to the tag stack.
</description>
</method>
<methodname="push_font">
<returntype="void"/>
<argumentindex="0"name="font"type="Font"/>
<description>
Adds a [code][font][/code] tag to the tag stack. Overrides default fonts for its duration.
</description>
</method>
<methodname="push_indent">
<returntype="void"/>
<argumentindex="0"name="level"type="int"/>
<description>
Adds an [code][indent][/code] tag to the tag stack. Multiplies [code]level[/code] by current [member tab_size] to determine new margin length.
</description>
</method>
<methodname="push_italics">
<returntype="void"/>
<description>
Adds a [code][font][/code] tag with a italics font to the tag stack. This is the same as adding a [code][i][/code] tag if not currently in a [code][b][/code] tag.
Adds a [code][list][/code] tag to the tag stack. Similar to the BBCodes [code][ol][/code] or [code][ul][/code], but supports more list types. Not fully implemented!
</description>
</method>
<methodname="push_meta">
<returntype="void"/>
<argumentindex="0"name="data"type="Variant"/>
<description>
Adds a [code][meta][/code] tag to the tag stack. Similar to the BBCode [code][url=something]{text}[/url][/code], but supports non-[String] metadata types.
</description>
</method>
<methodname="push_mono">
<returntype="void"/>
<description>
Adds a [code][font][/code] tag with a monospace font to the tag stack.
</description>
</method>
<methodname="push_normal">
<returntype="void"/>
<description>
Adds a [code][font][/code] tag with a normal font to the tag stack.
</description>
</method>
<methodname="push_strikethrough">
<returntype="void"/>
<description>
Adds a [code][s][/code] tag to the tag stack.
</description>
</method>
<methodname="push_table">
<returntype="void"/>
<argumentindex="0"name="columns"type="int"/>
<description>
Adds a [code][table=columns][/code] tag to the tag stack.
</description>
</method>
<methodname="push_underline">
<returntype="void"/>
<description>
Adds a [code][u][/code] tag to the tag stack.
</description>
</method>
<methodname="remove_line">
<returntype="bool"/>
<argumentindex="0"name="line"type="int"/>
<description>
Removes a line of content from the label. Returns [code]true[/code] if the line exists.
The [code]line[/code] argument is the index of the line to remove, it can take values in the interval [code][0, get_line_count() - 1][/code].
</description>
</method>
<methodname="scroll_to_line">
<returntype="void"/>
<argumentindex="0"name="line"type="int"/>
<description>
Scrolls the window's top line to match [code]line[/code].
</description>
</method>
<methodname="set_table_column_expand">
<returntype="void"/>
<argumentindex="0"name="column"type="int"/>
<argumentindex="1"name="expand"type="bool"/>
<argumentindex="2"name="ratio"type="int"/>
<description>
Edits the selected column's expansion options. If [code]expand[/code] is [code]true[/code], the column expands in proportion to its expansion ratio versus the other columns' ratios.
For example, 2 columns with ratios 3 and 4 plus 70 pixels in available width would expand 30 and 40 pixels, respectively.
If [code]expand[/code] is [code]false[/code], the column will not contribute to the total ratio.
If [code]true[/code], the label uses BBCode formatting.
[b]Note:[/b] Trying to alter the [RichTextLabel]'s text with [method add_text] will reset this to [code]false[/code]. Use instead [method append_bbcode] to preserve BBCode formatting.
The label's text in BBCode format. Is not representative of manual modifications to the internal tag stack. Erases changes made by other methods when edited.
[b]Note:[/b] It is unadvised to use the [code]+=[/code] operator with [code]bbcode_text[/code] (e.g. [code]bbcode_text += "some string"[/code]) as it replaces the whole text and can cause slowdowns. It will also erase all BBCode that was added to stack using [code]push_*[/code] methods. Use [method append_bbcode] for adding text instead, unless you absolutely need to close a tag that was opened in an earlier method call.
If [code]true[/code], the label's height will be automatically updated to fit its content.
[b]Note:[/b] This property is used as a workaround to fix issues with [RichTextLabel] in [Container]s, but it's unreliable in some cases and will be removed in future versions.
The restricted number of characters to display in the label. If [code]-1[/code], all characters will be displayed.
[b]Note:[/b] Setting this property updates [member percent_visible] based on current [method get_total_character_count].
</member>
</members>
<signals>
<signalname="meta_clicked">
<argumentindex="0"name="meta"type="Variant"/>
<description>
Triggered when the user clicks on content between meta tags. If the meta is defined in text, e.g. [code][url={"data"="hi"}]hi[/url][/code], then the parameter for this signal will be a [String] type. If a particular type or an object is desired, the [method push_meta] method must be used to manually insert the data into the tag stack.