Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

RichTextLabel

Hereda: Control < CanvasItem < Node < Object

Un control para mostrar texto que puede contener diferentes estilos de fuente, imágenes y formato básico.

Descripción

A control for displaying text that can contain custom fonts, images, and basic formatting. RichTextLabel manages these as an internal tag stack. It also adapts itself to given width/heights.

Note: newline(), push_paragraph(), "\n", "\r\n", the p tag, and alignment tags start a new paragraph. Each paragraph is processed independently, in its own BiDi context. If you want to force line wrapping within a paragraph, any other line breaking character can be used, for example, Form Feed (U+000C), Next Line (U+0085), Line Separator (U+2028).

Note: Assignments to text clear the tag stack and reconstruct it from the property's contents. Any edits made to text will erase previous edits made from other manual sources such as append_text() and the push_* / pop() methods.

Note: RichTextLabel doesn't support entangled BBCode tags. For example, instead of using [b]bold[i]bold italic[/b]italic[/i], use [b]bold[i]bold italic[/i][/b][i]italic[/i].

Note: push_*/pop_* functions won't affect BBCode.

Note: While bbcode_enabled is enabled, alignment tags such as [center] will take priority over the horizontal_alignment setting which determines the default text alignment.

Tutoriales

Propiedades

AutowrapMode

autowrap_mode

3

BitField[LineBreakFlag]

autowrap_trim_flags

192

bool

bbcode_enabled

false

bool

clip_contents

true (overrides Control)

bool

context_menu_enabled

false

Array

custom_effects

[]

bool

deselect_on_focus_loss_enabled

true

bool

drag_and_drop_selection_enabled

true

bool

fit_content

false

FocusMode

focus_mode

3 (overrides Control)

bool

hint_underlined

true

HorizontalAlignment

horizontal_alignment

0

BitField[JustificationFlag]

justification_flags

163

String

language

""

int

maximum_font_size

60

bool

meta_underlined

true

int

minimum_font_size

10

int

progress_bar_delay

1000

bool

resize_font_to_fit

false

BitField[ResourceAccessFlag]

resource_access_flags

3

bool

scroll_active

true

bool

scroll_following

false

bool

scroll_following_visible_characters

false

bool

selection_enabled

false

bool

shortcut_keys_enabled

true

StructuredTextParser

structured_text_bidi_override

0

Array

structured_text_bidi_override_options

[]

int

tab_size

4

PackedFloat32Array

tab_stops

PackedFloat32Array()

String

text

""

TextDirection

text_direction

0

bool

threaded

false

VerticalAlignment

vertical_alignment

0

int

visible_characters

-1

VisibleCharactersBehavior

visible_characters_behavior

0

float

visible_ratio

1.0

Métodos

void

add_hr(width: int = 90, height: int = 2, color: Color = Color(1, 1, 1, 1), alignment: HorizontalAlignment = 1, width_in_percent: bool = true, height_in_percent: bool = false)

void

add_image(image: Texture2D, width: float = 0, height: float = 0, color: Color = Color(1, 1, 1, 1), inline_align: InlineAlignment = 5, region: Rect2 = Rect2(0, 0, 0, 0), key: Variant = null, pad: bool = false, tooltip: String = "", width_unit: ImageUnit = 0, height_unit: ImageUnit = 0, alt_text: String = "")

void

add_text(text: String)

void

append_text(bbcode: String)

void

clear()

void

deselect()

int

get_character_line(character: int)

int

get_character_paragraph(character: int)

int

get_content_height() const

int

get_content_width() const

int

get_line_count() const

int

get_line_height(line: int) const

float

get_line_offset(line: int)

Vector2i

get_line_range(line: int)

int

get_line_width(line: int) const

PopupMenu

get_menu() const

int

get_paragraph_count() const

float

get_paragraph_offset(paragraph: int)

String

get_parsed_text() const

int

get_rendered_font_size() const

String

get_selected_text() const

int

get_selection_from() const

float

get_selection_line_offset() const

int

get_selection_to() const

int

get_total_character_count() const

VScrollBar

get_v_scroll_bar()

Rect2i

get_visible_content_rect() const

int

get_visible_line_count() const

int

get_visible_paragraph_count() const

void

install_effect(effect: Variant)

bool

invalidate_paragraph(paragraph: int)

bool

is_finished() const

bool

is_menu_visible() const

bool

is_ready() const

void

menu_option(option: int)

void

newline()

void

parse_bbcode(bbcode: String)

Dictionary

parse_expressions_for_values(expressions: PackedStringArray)

void

pop()

void

pop_all()

void

pop_context()

void

push_bgcolor(bgcolor: Color)

void

push_bold()

void

push_bold_italics()

void

push_cell()

void

push_color(color: Color)

void

push_context()

void

push_customfx(effect: RichTextEffect, env: Dictionary)

void

push_dropcap(string: String, font: Font, size: int, dropcap_margins: Rect2 = Rect2(0, 0, 0, 0), color: Color = Color(1, 1, 1, 1), outline_size: int = 0, outline_color: Color = Color(0, 0, 0, 0))

void

push_fgcolor(fgcolor: Color)

void

push_font(font: Font, font_size: int = 0)

void

push_font_size(font_size: int)

void

push_hint(description: String)

void

push_indent(level: int)

void

push_italics()

void

push_language(language: String)

void

push_list(level: int, type: ListType, capitalize: bool, bullet: String = "•")

void

push_meta(data: Variant, underline_mode: MetaUnderline = 1, tooltip: String = "")

void

push_mono()

void

push_normal()

void

push_outline_color(color: Color)

void

push_outline_size(outline_size: int)

void

push_paragraph(alignment: HorizontalAlignment, base_direction: TextDirection = 0, language: String = "", st_parser: StructuredTextParser = 0, justification_flags: BitField[JustificationFlag] = 163, tab_stops: PackedFloat32Array = PackedFloat32Array())

void

push_strikethrough(color: Color = Color(0, 0, 0, 0))

void

push_table(columns: int, inline_align: InlineAlignment = 0, align_to_row: int = -1, name: String = "")

void

push_underline(color: Color = Color(0, 0, 0, 0))

void

reload_effects()

bool

remove_paragraph(paragraph: int, no_invalidate: bool = false)

void

scroll_to_line(line: int)

void

scroll_to_paragraph(paragraph: int)

void

scroll_to_selection()

void

select_all()

void

set_cell_border_color(color: Color)

void

set_cell_padding(padding: Rect2)

void

set_cell_row_background_color(odd_row_bg: Color, even_row_bg: Color)

void

set_cell_size_override(min_size: Vector2, max_size: Vector2)

void

set_table_column_expand(column: int, expand: bool, ratio: int = 1, shrink: bool = true)

void

set_table_column_name(column: int, name: String)

void

update_image(key: Variant, mask: BitField[ImageUpdateMask], image: Texture2D, width: float = 0, height: float = 0, color: Color = Color(1, 1, 1, 1), inline_align: InlineAlignment = 5, region: Rect2 = Rect2(0, 0, 0, 0), pad: bool = false, tooltip: String = "", width_unit: ImageUnit = 0, height_unit: ImageUnit = 0)

Propiedades del tema

Color

default_color

Color(1, 1, 1, 1)

Color

font_outline_color

Color(0, 0, 0, 1)

Color

font_selected_color

Color(0, 0, 0, 0)

Color

font_shadow_color

Color(0, 0, 0, 0)

Color

selection_color

Color(0.1, 0.1, 1, 0.8)

Color

table_border

Color(0, 0, 0, 0)

Color

table_even_row_bg

Color(0, 0, 0, 0)

Color

table_odd_row_bg

Color(0, 0, 0, 0)

int

line_separation

0

int

outline_size

0

int

paragraph_separation

0

int

shadow_offset_x

1

int

shadow_offset_y

1

int

shadow_outline_size

1

int

strikethrough_alpha

50

int

table_h_separation

3

int

table_v_separation

3

int

text_highlight_h_padding

3

int

text_highlight_v_padding

3

int

underline_alpha

50

Font

bold_font

Font

bold_italics_font

Font

italics_font

Font

mono_font

Font

normal_font

int

bold_font_size

int

bold_italics_font_size

int

italics_font_size

int

mono_font_size

int

normal_font_size

Texture2D

horizontal_rule

StyleBox

focus

StyleBox

normal


Señales

finished() 🔗

Se activa cuando el documento se ha cargado por completo.

Nota: Esto puede ocurrir antes de que el texto se procese para su dibujo. Los valores de desplazamiento pueden no ser válidos hasta que el documento se dibuje por primera vez después de esta señal.


meta_clicked(meta: Variant) 🔗

Triggered when the user clicks on content between meta (URL) tags. If the meta is defined in BBCode, e.g. [url={"key": "value"}]Text[/url], then the parameter for this signal will always be a String type. If a particular type or an object is desired, the push_meta() method must be used to manually insert the data into the tag stack. Alternatively, you can convert the String input to the desired type based on its contents (such as calling JSON.parse() on it).

For example, the following method can be connected to meta_clicked to open clicked URLs using the user's default web browser:

# This assumes RichTextLabel's `meta_clicked` signal was connected to
# the function below using the signal connection dialog.
func _richtextlabel_on_meta_clicked(meta):
    # `meta` is of Variant type, so convert it to a String to avoid script errors at run-time.
    OS.shell_open(str(meta))

meta_hover_ended(meta: Variant) 🔗

Se activa cuando el ratón sale de una meta etiqueta.


meta_hover_started(meta: Variant) 🔗

Se activa cuando el ratón sale de una meta etiqueta.


Enumeraciones

enum ListType: 🔗

ListType LIST_NUMBERS = 0

Cada elemento de la lista tiene un marcador numérico.

ListType LIST_LETTERS = 1

Cada elemento de la lista tiene un marcador de letras.

ListType LIST_ROMAN = 2

Each list item has a Roman numeral marker.

ListType LIST_DOTS = 3

Cada elemento de la lista tiene un marcador de círculo lleno.


enum MenuItems: 🔗

MenuItems MENU_COPY = 0

Copia el texto seleccionado.

MenuItems MENU_SELECT_ALL = 1

Selecciona todo el texto del RichTextLabel.

MenuItems MENU_MAX = 2

Representa el tamaño del enum MenuItems.


enum MetaUnderline: 🔗

MetaUnderline META_UNDERLINE_NEVER = 0

The meta tag does not display an underline, even if meta_underlined is true.

MetaUnderline META_UNDERLINE_ALWAYS = 1

If meta_underlined is true, the meta tag always displays an underline.

MetaUnderline META_UNDERLINE_ON_HOVER = 2

If meta_underlined is true, the meta tag displays an underline when hovered by the mouse cursor.


flags ImageUpdateMask: 🔗

ImageUpdateMask UPDATE_TEXTURE = 1

Si este bit está activado, update_image() cambia la textura de la imagen.

ImageUpdateMask UPDATE_SIZE = 2

Si este bit está activado, update_image() cambia el tamaño de la imagen.

ImageUpdateMask UPDATE_COLOR = 4

Si este bit está activado, update_image() cambia el color de la imagen.

ImageUpdateMask UPDATE_ALIGNMENT = 8

Si este bit está activado, update_image() cambia la alineación en línea de la imagen.

ImageUpdateMask UPDATE_REGION = 16

Si este bit está activado, update_image() cambia la región de la textura de la imagen.

ImageUpdateMask UPDATE_PAD = 32

Si este bit está activado, update_image() cambia el relleno de la imagen.

ImageUpdateMask UPDATE_TOOLTIP = 64

Si este bit está activado, update_image() cambia la información sobre herramientas de la imagen.

ImageUpdateMask UPDATE_WIDTH_UNIT = 128

If this bit is set, update_image() changes the units used to calculate image size.


flags ResourceAccessFlag: 🔗

ResourceAccessFlag RESOURCE_ACCESS_RESOURCES = 1

Allows accessing files under the Resource path (res://).

ResourceAccessFlag RESOURCE_ACCESS_USERDATA = 2

Allows accessing files under the user data path (user://).

ResourceAccessFlag RESOURCE_ACCESS_FILESYSTEM = 4

Allows accessing files on the whole local file system.

ResourceAccessFlag RESOURCE_ACCESS_PIPE = 8

Allows accessing named pipes (pipe://).

ResourceAccessFlag RESOURCE_ACCESS_NETWORK = 16

Allows accessing files on network shares.


enum ImageUnit: 🔗

ImageUnit IMAGE_UNIT_PIXEL = 0

Image size is given in pixels.

ImageUnit IMAGE_UNIT_PERCENT = 1

Image size is given as a percentage of the RichTextLabel's width.

ImageUnit IMAGE_UNIT_EM = 2

Image size is given as a multiplier of the surrounding font size.


Descripciones de propiedades

AutowrapMode autowrap_mode = 3 🔗

If set to something other than TextServer.AUTOWRAP_OFF, the text gets wrapped inside the node's bounding rectangle.

Note: RichTextLabels with autowrapping and fit_content enabled must have a custom maximum width configured to work correctly, either through the RichTextLabel's own Control.custom_maximum_size or as a result of a propagated maximum size from a parent Control with Control.propagate_maximum_size enabled.


BitField[LineBreakFlag] autowrap_trim_flags = 192 🔗

Flags de recorte de espacio de ajuste automático. Véase TextServer.BREAK_TRIM_START_EDGE_SPACES y TextServer.BREAK_TRIM_END_EDGE_SPACES para más información.


bool bbcode_enabled = false 🔗

  • void set_use_bbcode(value: bool)

  • bool is_using_bbcode()

Si es true, la etiqueta utiliza formato BBCode.

Nota: Esto solo afecta al contenido de text, no a la pila de etiquetas.


bool context_menu_enabled = false 🔗

  • void set_context_menu_enabled(value: bool)

  • bool is_context_menu_enabled()

Si es true, un clic con el botón derecho del ratón muestra el menú contextual.


Array custom_effects = [] 🔗

  • void set_effects(value: Array)

  • Array get_effects()

Los efectos personalizados actualmente instalados. Este es un conjunto de RichTextEffect.

Para añadir un efecto personalizado, es más conveniente usar install_effect().


bool deselect_on_focus_loss_enabled = true 🔗

  • void set_deselect_on_focus_loss_enabled(value: bool)

  • bool is_deselect_on_focus_loss_enabled()

Si es true, el texto seleccionado se deseleccionará cuando se pierda el foco.


bool drag_and_drop_selection_enabled = true 🔗

  • void set_drag_and_drop_selection_enabled(value: bool)

  • bool is_drag_and_drop_selection_enabled()

Si es true, permite arrastrar y soltar el texto seleccionado.


bool fit_content = false 🔗

  • void set_fit_content(value: bool)

  • bool is_fit_content_enabled()

If true, the label's minimum size will be automatically updated to fit its content, matching the behavior of Label.

Note: RichTextLabels with autowrapping and fit_content enabled must have a custom maximum width configured to work correctly, either through the RichTextLabel's own Control.custom_maximum_size or as a result of a propagated maximum size from a parent Control with Control.propagate_maximum_size enabled.


bool hint_underlined = true 🔗

  • void set_hint_underline(value: bool)

  • bool is_hint_underlined()

Si es true, la etiqueta subraya las etiquetas de sugerencia como [hint=description]{text}[/hint].


HorizontalAlignment horizontal_alignment = 0 🔗

Controla la alineación horizontal del texto. Admite izquierda, centro, derecha y relleno (también conocido como justificar).


BitField[JustificationFlag] justification_flags = 163 🔗

Reglas de alineación de relleno de línea.


String language = "" 🔗

Código de idioma utilizado para los algoritmos de salto de línea y de formación de texto. Si se deja vacío, se utiliza la configuración regional actual.


int maximum_font_size = 60 🔗

  • void set_maximum_font_size(value: int)

  • int get_maximum_font_size()

The maximum font size used when resize_font_to_fit is enabled. If minimum_font_size is greater than maximum_font_size, the minimum font size takes precedence.


bool meta_underlined = true 🔗

  • void set_meta_underline(value: bool)

  • bool is_meta_underlined()

Si es true, la etiqueta subraya las metaetiquetas como [url]{text}[/url]. Estas etiquetas pueden llamar a una función cuando se hace clic si meta_clicked está conectado a una función.


int minimum_font_size = 10 🔗

  • void set_minimum_font_size(value: int)

  • int get_minimum_font_size()

The minimum font size used when resize_font_to_fit is enabled. Also determines the minimum vertical size of this RichTextLabel, potentially used by a parent Container. If minimum_font_size is greater than maximum_font_size, the minimum font size takes precedence.


int progress_bar_delay = 1000 🔗

  • void set_progress_bar_delay(value: int)

  • int get_progress_bar_delay()

The delay after which the loading progress bar is displayed, in milliseconds. Set to -1 to disable the progress bar entirely.

Note: The progress bar is displayed only if threaded is enabled.


bool resize_font_to_fit = false 🔗

  • void set_resize_font_to_fit(value: bool)

  • bool is_resize_font_to_fit_enabled()

If true, the text size will automatically shrink or grow to fit within the node's bounding rectangle. It will pick the largest font size between minimum_font_size and maximum_font_size that doesn't cause the text to be truncated.

Font sizes that are overridden with the [font_size] tag are scaled relative to the theme font size. For example, if the theme font size is 16 and [font_size=24] is used with an automatic font size determined to be 32, text in the overridden block will be in size 48.


BitField[ResourceAccessFlag] resource_access_flags = 3 🔗

The set of locations BBCode is allowed to load resource files from.


bool scroll_active = true 🔗

  • void set_scroll_active(value: bool)

  • bool is_scroll_active()

Si es true, la barra de desplazamiento es visible. Ponerla en false no bloquea completamente el desplazamiento. Véase scroll_to_line().


bool scroll_following = false 🔗

  • void set_scroll_follow(value: bool)

  • bool is_scroll_following()

Si es true, la ventana se desplaza hacia abajo para mostrar automáticamente el nuevo contenido.


bool scroll_following_visible_characters = false 🔗

  • void set_scroll_follow_visible_characters(value: bool)

  • bool is_scroll_following_visible_characters()

Si es true, la ventana se desplaza para mostrar la última línea visible cuando se cambia visible_characters o visible_ratio.


bool selection_enabled = false 🔗

  • void set_selection_enabled(value: bool)

  • bool is_selection_enabled()

Si es true, la etiqueta permite la selección de texto.


bool shortcut_keys_enabled = true 🔗

  • void set_shortcut_keys_enabled(value: bool)

  • bool is_shortcut_keys_enabled()

Si es true, las teclas de atajo para los elementos del menú contextual están habilitadas, incluso si el menú contextual está desactivado.


StructuredTextParser structured_text_bidi_override = 0 🔗

Establece la sobrescritura del algoritmo BiDi para el texto estructurado.


Array structured_text_bidi_override_options = [] 🔗

  • void set_structured_text_bidi_override_options(value: Array)

  • Array get_structured_text_bidi_override_options()

Establece opciones adicionales para la sobrescritura BiDi.


int tab_size = 4 🔗

  • void set_tab_size(value: int)

  • int get_tab_size()

The number of spaces associated with a single tab length. Does not affect \t in text tags, only indent tags.


PackedFloat32Array tab_stops = PackedFloat32Array() 🔗

Alinea el texto con las tabulaciones indicadas.

Note: The returned array is copied and any changes to it will not update the original property value. See PackedFloat32Array for more details.


String text = "" 🔗

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.

Note: If bbcode_enabled is true, it is recommended not to use the += operator with text (e.g., text += "some string") as it replaces the whole text and can cause slowdowns. It will also erase all BBCode that was added to the stack using the push_* methods. Use append_text() for adding text instead, unless you absolutely need to close a tag that was opened in an earlier method call.


TextDirection text_direction = 0 🔗

Dirección base de escritura del texto.


bool threaded = false 🔗

  • void set_threaded(value: bool)

  • bool is_threaded()

Si es true, el procesamiento del texto se realiza en un hilo secundario.


VerticalAlignment vertical_alignment = 0 🔗

Controla la alineación vertical del texto. Admite superior, centro, inferior y relleno.


int visible_characters = -1 🔗

  • void set_visible_characters(value: int)

  • int get_visible_characters()

El número de caracteres a mostrar. Si se establece en -1, se muestran todos los caracteres. Esto puede ser útil al animar el texto que aparece en un cuadro de diálogo.

Nota: Establecer esta propiedad actualiza visible_ratio en consecuencia.

Nota: Los caracteres se cuentan como puntos de código Unicode. Un solo grafema visible puede contener múltiples puntos de código (por ejemplo, algunos emojis usan tres puntos de código). Un solo punto de código puede contener dos caracteres UTF-16, que se usan en las cadenas de C#.


VisibleCharactersBehavior visible_characters_behavior = 0 🔗

El comportamiento de recorte cuando se establece visible_characters o visible_ratio.


float visible_ratio = 1.0 🔗

  • void set_visible_ratio(value: float)

  • float get_visible_ratio()

The fraction of characters to display, relative to the total number of characters (see get_total_character_count()). If set to 1.0, all characters are displayed. If set to 0.5, only half of the characters are displayed. This can be useful when animating the text appearing in a dialog box.

Note: Setting this property updates visible_characters accordingly.


Descripciones de métodos

void add_hr(width: int = 90, height: int = 2, color: Color = Color(1, 1, 1, 1), alignment: HorizontalAlignment = 1, width_in_percent: bool = true, height_in_percent: bool = false) 🔗

Agrega una regla horizontal que se puede usar para separar el contenido.

Si width_in_percent está establecido, los valores de width son porcentajes del ancho del control en lugar de píxeles.

Si height_in_percent está establecido, los valores de height son porcentajes del ancho del control en lugar de píxeles.


void add_image(image: Texture2D, width: float = 0, height: float = 0, color: Color = Color(1, 1, 1, 1), inline_align: InlineAlignment = 5, region: Rect2 = Rect2(0, 0, 0, 0), key: Variant = null, pad: bool = false, tooltip: String = "", width_unit: ImageUnit = 0, height_unit: ImageUnit = 0, alt_text: String = "") 🔗

Adds an image's opening and closing tags to the tag stack, optionally providing a width and height to resize the image, a color to tint the image and a region to only use parts of the image.

If width or height is set to 0, the image size will be adjusted in order to keep the original aspect ratio.

If width and height are not set, but region is, the region's rect will be used.

key is an optional identifier, that can be used to modify the image via update_image().

If pad is set, and the image is smaller than the size specified by width and height, the image padding is added to match the size instead of upscaling.

Parameters width_unit and height_unit determine the units used to calculate the image width and height, respectively.

alt_text is used as the image description for assistive apps.


void add_text(text: String) 🔗

Añade texto crudo no preparado por BBCode a la pila de etiquetas.


void append_text(bbcode: String) 🔗

Analiza bbcode y agrega etiquetas a la pila de etiquetas según sea necesario.

Nota: Usando este método, no puedes cerrar una etiqueta que se abrió en una llamada anterior a append_text(). Esto se hace para mejorar el rendimiento, especialmente al actualizar RichTextLabels grandes, ya que reconstruir todo el BBCode cada vez sería más lento. Si absolutamente necesitas cerrar una etiqueta en una llamada de método futura, agrega text en lugar de usar append_text().


void clear() 🔗

Borra la pila de etiquetas, haciendo que la etiqueta no muestre nada.

Nota: Este método no afecta a text, y su contenido se mostrará de nuevo si la etiqueta se vuelve a dibujar. Sin embargo, establecer text en una String vacía también borra la pila.


void deselect() 🔗

Borra la selección actual.


int get_character_line(character: int) 🔗

Returns the line number of the character position provided. Line and character numbers are both zero-indexed.

Note: If threaded is enabled, this method returns a value for the loaded part of the document. Use is_finished() or finished to determine whether the document is fully loaded.


int get_character_paragraph(character: int) 🔗

Returns the paragraph number of the character position provided. Paragraph and character numbers are both zero-indexed.

Note: If threaded is enabled, this method returns a value for the loaded part of the document. Use is_finished() or finished to determine whether the document is fully loaded.


int get_content_height() const 🔗

Returns the height of the content.

Note: This method always returns the full content size, and is not affected by visible_ratio and visible_characters. To get the visible content size, use get_visible_content_rect().

Note: If threaded is enabled, this method returns a value for the loaded part of the document. Use is_finished() or finished to determine whether the document is fully loaded.


int get_content_width() const 🔗

Returns the width of the content.

Note: This method always returns the full content size, and is not affected by visible_ratio and visible_characters. To get the visible content size, use get_visible_content_rect().

Note: If threaded is enabled, this method returns a value for the loaded part of the document. Use is_finished() or finished to determine whether the document is fully loaded.


int get_line_count() const 🔗

Returns the total number of lines in the text. Wrapped text is counted as multiple lines.

Note: If threaded is enabled, this method returns a value for the loaded part of the document. Use is_finished() or finished to determine whether the document is fully loaded.


int get_line_height(line: int) const 🔗

Devuelve la altura de la línea encontrada en el índice proporcionado.

Nota: Si threaded está habilitado, este método devuelve un valor para la parte cargada del documento. Usa is_finished() o finished para determinar si el documento está completamente cargado.


float get_line_offset(line: int) 🔗

Returns the vertical offset of the line found at the provided index.

Note: If threaded is enabled, this method returns a value for the loaded part of the document. Use is_finished() or finished to determine whether the document is fully loaded.


Vector2i get_line_range(line: int) 🔗

Returns the indexes of the first and last visible characters for the given line, as a Vector2i.

Note: If visible_characters_behavior is set to TextServer.VC_CHARS_BEFORE_SHAPING only visible wrapped lines are counted.

Note: If threaded is enabled, this method returns a value for the loaded part of the document. Use is_finished() or finished to determine whether the document is fully loaded.


int get_line_width(line: int) const 🔗

Devuelve el ancho de la línea encontrada en el índice proporcionado.

Nota: Si threaded está habilitado, este método devuelve un valor para la parte cargada del documento. Usa is_finished() o finished para determinar si el documento está completamente cargado.


PopupMenu get_menu() const 🔗

Returns the PopupMenu of this RichTextLabel. By default, this menu is displayed when right-clicking on the RichTextLabel.

You can add custom menu items or remove standard ones. Make sure your IDs don't conflict with the standard ones (see MenuItems). For example:

func _ready():
    var menu = get_menu()
    # Remove "Select All" item.
    menu.remove_item(MENU_SELECT_ALL)
    # Add custom items.
    menu.add_separator()
    menu.add_item("Duplicate Text", MENU_MAX + 1)
    # Connect callback.
    menu.id_pressed.connect(_on_item_pressed)

func _on_item_pressed(id):
    if id == MENU_MAX + 1:
        add_text("\n" + get_parsed_text())

Warning: 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 Window.visible property.


int get_paragraph_count() const 🔗

Devuelve el número total de párrafos (saltos de línea o etiquetas p en las etiquetas de texto de la pila de etiquetas). Considera el texto ajustado como un párrafo.


float get_paragraph_offset(paragraph: int) 🔗

Returns the vertical offset of the paragraph found at the provided index.

Note: If threaded is enabled, this method returns a value for the loaded part of the document. Use is_finished() or finished to determine whether the document is fully loaded.


String get_parsed_text() const 🔗

Devuelve el texto sin el marcado BBCode.


int get_rendered_font_size() const 🔗

Returns the font size that is currently used for rendering. When resize_font_to_fit is enabled, this returns the automatically calculated font size. Otherwise, it returns the theme font size.


String get_selected_text() const 🔗

Devuelve el texto de la selección actual. No incluye los BBCodes.


int get_selection_from() const 🔗

Returns the current selection's first character index if a selection is active, -1 otherwise. Does not include BBCodes.


float get_selection_line_offset() const 🔗

Returns the current selection's vertical line offset if a selection is active, -1.0 otherwise.


int get_selection_to() const 🔗

Returns the current selection's last character index if a selection is active, -1 otherwise. Does not include BBCodes.


int get_total_character_count() const 🔗

Devuelve el número total de caracteres de las etiquetas de texto. No incluye los BBCodes.


VScrollBar get_v_scroll_bar() 🔗

Devuelve la barra de desplazamiento vertical.

Advertencia: Este es un nodo interno requerido, eliminarlo y liberarlo puede causar un crasheo. Si deseas ocultarlo o a alguno de sus hijos, usa su propiedad CanvasItem.visible.


Rect2i get_visible_content_rect() const 🔗

Returns the bounding rectangle of the visible content.

Note: This method returns a correct value only after the label has been drawn.

extends RichTextLabel

@export var background_panel: Panel

func _ready():
    await draw
    background_panel.position = get_visible_content_rect().position
    background_panel.size = get_visible_content_rect().size

int get_visible_line_count() const 🔗

Returns the number of visible lines.

Note: This method returns a correct value only after the label has been drawn.

Note: If threaded is enabled, this method returns a value for the loaded part of the document. Use is_finished() or finished to determine whether the document is fully loaded.


int get_visible_paragraph_count() const 🔗

Returns the number of visible paragraphs. A paragraph is considered visible if at least one of its lines is visible.

Note: This method returns a correct value only after the label has been drawn.

Note: If threaded is enabled, this method returns a value for the loaded part of the document. Use is_finished() or finished to determine whether the document is fully loaded.


void install_effect(effect: Variant) 🔗

Installs a custom effect. This can also be done in the Inspector through the custom_effects property. effect should be a valid RichTextEffect.

Example: With the following script extending from RichTextEffect:

# effect.gd
class_name MyCustomEffect
extends RichTextEffect

var bbcode = "my_custom_effect"

# ...

The above effect can be installed in RichTextLabel from a script:

# rich_text_label.gd
extends RichTextLabel

func _ready():
    install_effect(MyCustomEffect.new())

    # Alternatively, if not using `class_name` in the script that extends RichTextEffect:
    install_effect(preload("res://effect.gd").new())

bool invalidate_paragraph(paragraph: int) 🔗

Invalida paragraph y todas las cachés de párrafos siguientes.


bool is_finished() const 🔗

If threaded is enabled, returns true if the background thread has finished text processing, otherwise always returns true.


bool is_menu_visible() const 🔗

Devuelve si el menú está visible. Utiliza esto en lugar de get_menu().visible para mejorar el rendimiento (para que se evite la creación del menú).


bool is_ready() const 🔗

Obsoleto: Use is_finished() instead.

If threaded is enabled, returns true if the background thread has finished text processing, otherwise always returns true.


void menu_option(option: int) 🔗

Ejecuta una acción determinada según se define en el enum MenuItems.


void newline() 🔗

Añade una etiqueta de nueva línea a la pila de etiquetas.


void parse_bbcode(bbcode: String) 🔗

La versión de asignación de append_text(). Limpia la pila de etiquetas e inserta el nuevo contenido.


Dictionary parse_expressions_for_values(expressions: PackedStringArray) 🔗

Analiza el parámetro BBCode expressions en un diccionario.


void pop() 🔗

Termina la etiqueta actual. Utiliza después de push_* métodos para cerrar manualmente los BBCodes. No necesita seguir los métodos add_*.


void pop_all() 🔗

Termina todas las etiquetas abiertas por los métodos push_*.


void pop_context() 🔗

Termina las etiquetas abiertas después de la última llamada a push_context() (incluido el marcador de contexto), o todas las etiquetas si no hay un marcador de contexto en la pila.


void push_bgcolor(bgcolor: Color) 🔗

Añade una etiqueta [bgcolor] a la pila de etiquetas.

Nota: El color de fondo tiene un relleno aplicado por defecto, que se controla mediante text_highlight_h_padding y text_highlight_v_padding. Esto puede provocar resaltes superpuestos si los colores de fondo se colocan en líneas/columnas vecinas, por lo que considera la posibilidad de establecer esos elementos del tema en 0 si quieres evitar esto.


void push_bold() 🔗

Añade una etiqueta [font] con una fuente en negrita a la pila de etiquetas. Esto es lo mismo que añadir una etiqueta [b] si no está actualmente en una etiqueta [i].


void push_bold_italics() 🔗

Añade una etiqueta [font] con una fuente en negrita y cursiva a la pila de etiquetas.


void push_cell() 🔗

Adds a [cell] tag to the tag stack. Must be inside a [table] tag. See push_table() for details. Use set_table_column_expand() to set column expansion ratio, set_cell_border_color() to set cell border, set_cell_row_background_color() to set cell background, set_cell_size_override() to override cell size, and set_cell_padding() to set padding.


void push_color(color: Color) 🔗

Adds a [color] tag to the tag stack.


void push_context() 🔗

Añade un marcador de contexto a la pila de etiquetas. Véase pop_context().


void push_customfx(effect: RichTextEffect, env: Dictionary) 🔗

Añade una etiqueta de efecto personalizado a la pila de etiquetas. El efecto no necesita estar en custom_effects. El entorno se pasa directamente al efecto.


void push_dropcap(string: String, font: Font, size: int, dropcap_margins: Rect2 = Rect2(0, 0, 0, 0), color: Color = Color(1, 1, 1, 1), outline_size: int = 0, outline_color: Color = Color(0, 0, 0, 0)) 🔗

Añade una etiqueta [dropcap] a la pila de etiquetas. La letra capitular es un elemento decorativo al principio de un párrafo que es más grande que el resto del texto.


void push_fgcolor(fgcolor: Color) 🔗

Añade una etiqueta [fgcolor] a la pila de etiquetas.

Nota: El color de primer plano tiene un relleno aplicado por defecto, que se controla mediante text_highlight_h_padding y text_highlight_v_padding. Esto puede provocar resaltes superpuestos si los colores de primer plano se colocan en líneas/columnas vecinas, así que considera establecer esos elementos del tema a 0 si quieres evitar esto.


void push_font(font: Font, font_size: int = 0) 🔗

Añade una etiqueta [font] a la pila de etiquetas. Sobrescribe las fuentes predeterminadas durante su duración.

Si se pasa 0 a font_size, se utilizará el tamaño de fuente predeterminado existente.


void push_font_size(font_size: int) 🔗

Añade una etiqueta [font_size] a la pila de etiquetas. Sobrescribe el tamaño de fuente predeterminado durante su duración.


void push_hint(description: String) 🔗

Añade una etiqueta [hint] a la pila de etiquetas. Es lo mismo que el BBCode [hint=something]{text}[/hint].


void push_indent(level: int) 🔗

Añade una etiqueta [indent] a la pila de etiquetas. Multiplica level por tab_size actual para determinar la nueva longitud del margen.


void push_italics() 🔗

Añade una etiqueta [font] con una fuente en cursiva a la pila de etiquetas. Esto es lo mismo que añadir una etiqueta [i] si no está actualmente en una etiqueta [b].


void push_language(language: String) 🔗

Añade un código de idioma utilizado para el algoritmo de modelado de texto y características de fuente OpenType.


void push_list(level: int, type: ListType, capitalize: bool, bullet: String = "•") 🔗

Añade una etiqueta [ol] o [ul] a la pila de etiquetas. Multiplica level por el tab_size actual para determinar la nueva longitud del margen.


void push_meta(data: Variant, underline_mode: MetaUnderline = 1, tooltip: String = "") 🔗

Añade una metaetiqueta a la pila de etiquetas. Similar al BBCode [url=algo]{text}[/url], pero admite tipos de metadatos que no son String.

Si meta_underlined es true, las metaetiquetas muestran un subrayado. Este comportamiento se puede personalizar con underline_mode.

Nota: Las metaetiquetas no hacen nada por defecto cuando se hace clic en ellas. Para asignar un comportamiento cuando se hace clic, conecta meta_clicked a una función que se llama cuando se hace clic en la metaetiqueta.


void push_mono() 🔗

Añade una etiqueta [font] con una fuente monoespaciada a la pila de etiquetas.


void push_normal() 🔗

Añade una etiqueta [font] con una fuente normal a la pila de etiquetas.


void push_outline_color(color: Color) 🔗

Añade una etiqueta [outline_color] a la pila de etiquetas. Añade un contorno al texto durante su duración.


void push_outline_size(outline_size: int) 🔗

Añade una etiqueta [outline_size] a la pila de etiquetas. Sobrescribe el tamaño predeterminado del contorno del texto durante su duración.


void push_paragraph(alignment: HorizontalAlignment, base_direction: TextDirection = 0, language: String = "", st_parser: StructuredTextParser = 0, justification_flags: BitField[JustificationFlag] = 163, tab_stops: PackedFloat32Array = PackedFloat32Array()) 🔗

Añade una etiqueta [p] a la pila de etiquetas.


void push_strikethrough(color: Color = Color(0, 0, 0, 0)) 🔗

Adds a [s] tag to the tag stack. If color's alpha value is 0.0, the current font's color with its alpha multiplied by strikethrough_alpha is used.


void push_table(columns: int, inline_align: InlineAlignment = 0, align_to_row: int = -1, name: String = "") 🔗

Añade una etiqueta [table=columns,inline_align] a la pila de etiquetas. Utiliza set_table_column_expand() para establecer la proporción de expansión de la columna. Utiliza push_cell() para añadir celdas. name se utiliza como el nombre de la tabla para las aplicaciones de asistencia.


void push_underline(color: Color = Color(0, 0, 0, 0)) 🔗

Adds a [u] tag to the tag stack. If color's alpha value is 0.0, the current font's color with its alpha multiplied by underline_alpha is used.


void reload_effects() 🔗

Recarga los efectos personalizados. Útil cuando custom_effects se modifica manualmente.


bool remove_paragraph(paragraph: int, no_invalidate: bool = false) 🔗

Removes a paragraph of content from the label. Returns true if the paragraph exists.

The paragraph argument is the index of the paragraph to remove, it can take values in the interval [0, get_paragraph_count() - 1].

If no_invalidate is set to true, the cache for the subsequent paragraphs is not invalidated. Use it for faster updates if the deleted paragraph is fully self-contained (has no unclosed tags), or this call is part of a complex edit operation and invalidate_paragraph() will be called at the end of the operation.


void scroll_to_line(line: int) 🔗

Desplaza la línea superior de la ventana para que coincida con line.


void scroll_to_paragraph(paragraph: int) 🔗

Scrolls the window's top line to match the first line of the paragraph.


void scroll_to_selection() 🔗

Se desplaza al principio de la selección actual.


void select_all() 🔗

Selects all the text.

If selection_enabled is false, no selection occurs.


void set_cell_border_color(color: Color) 🔗

Sets the color of a table cell's border.


void set_cell_padding(padding: Rect2) 🔗

Establece el relleno interior de una celda de la tabla.


void set_cell_row_background_color(odd_row_bg: Color, even_row_bg: Color) 🔗

Sets the color of a table cell. Separate colors for alternating rows can be specified.


void set_cell_size_override(min_size: Vector2, max_size: Vector2) 🔗

Establece las sobrescrituras de tamaño mínimo y máximo para una celda de la tabla.


void set_table_column_expand(column: int, expand: bool, ratio: int = 1, shrink: bool = true) 🔗

Edits the selected column's expansion options. If expand is true, 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 expand is false, the column will not contribute to the total ratio.


void set_table_column_name(column: int, name: String) 🔗

Establece el nombre de la columna de la tabla para las aplicaciones de asistencia.


void update_image(key: Variant, mask: BitField[ImageUpdateMask], image: Texture2D, width: float = 0, height: float = 0, color: Color = Color(1, 1, 1, 1), inline_align: InlineAlignment = 5, region: Rect2 = Rect2(0, 0, 0, 0), pad: bool = false, tooltip: String = "", width_unit: ImageUnit = 0, height_unit: ImageUnit = 0) 🔗

Actualiza las imágenes existentes con la clave key. Solo se actualizan las propiedades especificadas por los bits de mask. Véase add_image().


Descripciones de las propiedades del tema

Color default_color = Color(1, 1, 1, 1) 🔗

El color de texto por defecto.


Color font_outline_color = Color(0, 0, 0, 1) 🔗

El tinte predeterminado del contorno del texto.


Color font_selected_color = Color(0, 0, 0, 0) 🔗

El color del texto seleccionado, utilizado cuando selection_enabled es true. Si es igual a Color(0, 0, 0, 0), se ignorará.


Color font_shadow_color = Color(0, 0, 0, 0) 🔗

El color de la sombra de la fuente.


Color selection_color = Color(0.1, 0.1, 1, 0.8) 🔗

El color de la caja de selección.


Color table_border = Color(0, 0, 0, 0) 🔗

El color de borde de celda predeterminado.


Color table_even_row_bg = Color(0, 0, 0, 0) 🔗

El color de fondo predeterminado para las filas pares.


Color table_odd_row_bg = Color(0, 0, 0, 0) 🔗

El color de fondo predeterminado para las filas impares.


int line_separation = 0 🔗

Espacio vertical adicional entre líneas (en píxeles); el espacio se añade al descenso de la línea (line descent). Este valor puede ser negativo.


int outline_size = 0 🔗

El tamaño del contorno del texto.

Nota: Si se usa una fuente con FontFile.multichannel_signed_distance_field habilitado, su FontFile.msdf_pixel_range debe establecerse en al menos el doble del valor de outline_size para que el renderizado del contorno se vea correctamente. De lo contrario, el contorno puede parecer cortado antes de lo previsto.


int paragraph_separation = 0 🔗

Espacio vertical adicional entre párrafos (en píxeles). El espacio se añade después de la última línea. Este valor puede ser negativo.


int shadow_offset_x = 1 🔗

El desplazamiento horizontal de la sombra de la fuente.


int shadow_offset_y = 1 🔗

El desplazamiento vertical de la sombra de la fuente.


int shadow_outline_size = 1 🔗

El tamaño del contorno de la sombra.


int strikethrough_alpha = 50 🔗

La transparencia (porcentaje) predeterminada del color de tachado. Para los tachados con un color personalizado, este elemento del tema solo se utiliza si el alfa del color personalizado es 0.0 (totalmente transparente).


int table_h_separation = 3 🔗

La separación horizontal de elementos en una tabla.


int table_v_separation = 3 🔗

La separación vertical de elementos en una tabla.


int text_highlight_h_padding = 3 🔗

El relleno horizontal alrededor de los cuadros dibujados por las etiquetas [fgcolor] y [bgcolor]. Esto no afecta la apariencia de la selección de texto. Para evitar cualquier riesgo de que los resaltados vecinos se superpongan entre sí, establece esto en 0 para desactivar el relleno.


int text_highlight_v_padding = 3 🔗

El relleno vertical alrededor de los cuadros dibujados por las etiquetas [fgcolor] y [bgcolor]. Esto no afecta la apariencia de la selección de texto. Para evitar cualquier riesgo de que los resaltados vecinos se superpongan entre sí, establece esto en 0 para desactivar el relleno.


int underline_alpha = 50 🔗

El porcentaje de transparencia del color de subrayado predeterminado. Para subrayados con un color personalizado, este elemento de tema solo se usa si el alfa del color personalizado es 0.0 (totalmente transparente).


Font bold_font 🔗

La fuente usada para el texto en negrita.


Font bold_italics_font 🔗

La fuente usada para el texto en negrita y cursiva.


Font italics_font 🔗

La fuente usada para el texto en cursiva.


Font mono_font 🔗

La fuente usada para el texto monoespacio.


Font normal_font 🔗

La fuente por defecto.


int bold_font_size 🔗

El tamaño de fuente utilizado para texto en negrita.


int bold_italics_font_size 🔗

El tamaño de fuente utilizado para texto en negrita cursiva.


int italics_font_size 🔗

El tamaño de fuente utilizado para texto en cursiva.


int mono_font_size 🔗

El tamaño de fuente utilizado para el texto monoespaciado.


int normal_font_size 🔗

El tamaño de fuente predeterminado del texto.


Texture2D horizontal_rule 🔗

La textura de la regla horizontal.


StyleBox focus 🔗

The background used when the RichTextLabel is focused. The focus StyleBox is displayed over the base StyleBox, so a partially transparent StyleBox should be used to ensure the base StyleBox remains visible. A StyleBox that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a StyleBoxEmpty resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.


StyleBox normal 🔗

El fondo normal para el RichTextLabel.