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.

TextLine

Hérite de : RefCounted < Object

Contient une ligne de texte.

Description

Abstraction sur TextServer pour la manipulation d'une seule ligne de texte.

Propriétés

HorizontalAlignment

alignment

0

Direction

direction

0

String

ellipsis_char

"…"

BitField[JustificationFlag]

flags

3

Orientation

orientation

0

bool

preserve_control

false

bool

preserve_invalid

true

OverrunBehavior

text_overrun_behavior

3

float

width

-1.0

Méthodes

bool

add_object(key: Variant, size: Vector2, inline_align: InlineAlignment = 5, length: int = 1, baseline: float = 0.0)

bool

add_string(text: String, font: Font, font_size: int, language: String = "", meta: Variant = null)

void

clear()

void

draw(canvas: RID, pos: Vector2, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const

void

draw_outline(canvas: RID, pos: Vector2, outline_size: int = 1, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const

TextLine

duplicate() const

Direction

get_inferred_direction() const

float

get_line_ascent() const

float

get_line_descent() const

float

get_line_underline_position() const

float

get_line_underline_thickness() const

float

get_line_width() const

Rect2

get_object_rect(key: Variant) const

Array

get_objects() const

RID

get_rid() const

Vector2

get_size() const

bool

has_object(key: Variant) const

int

hit_test(coords: float) const

bool

resize_object(key: Variant, size: Vector2, inline_align: InlineAlignment = 5, baseline: float = 0.0)

void

set_bidi_override(override: Array)

void

tab_align(tab_stops: PackedFloat32Array)


Descriptions des propriétés

HorizontalAlignment alignment = 0 🔗

Définit l'alignement de texte dans la ligne comme si la ligne était horizontale.


Direction direction = 0 🔗

Direction d'écriture du texte.


String ellipsis_char = "…" 🔗

  • void set_ellipsis_char(value: String)

  • String get_ellipsis_char()

Caractère d’ellipse utilisé pour tronquer du texte.


BitField[JustificationFlag] flags = 3 🔗

Règles d'alignement de la ligne. Pour plus d'informations, voir TextServer.


Orientation orientation = 0 🔗

Orientation du texte.


bool preserve_control = false 🔗

  • void set_preserve_control(value: bool)

  • bool get_preserve_control()

Si défini à true, le texte affichera les caractères de contrôle.


bool preserve_invalid = true 🔗

  • void set_preserve_invalid(value: bool)

  • bool get_preserve_invalid()

Si défini à true, le texte affichera les caractères invalides.


OverrunBehavior text_overrun_behavior = 3 🔗

Le comportement de coupure lorsque le texte dépasse la largeur de la ligne de texte.


float width = -1.0 🔗

La largeur de la ligne de texte.


Descriptions des méthodes

bool add_object(key: Variant, size: Vector2, inline_align: InlineAlignment = 5, length: int = 1, baseline: float = 0.0) 🔗

Adds inline object to the text buffer, key must be unique. In the text, object is represented as length object replacement characters.


bool add_string(text: String, font: Font, font_size: int, language: String = "", meta: Variant = null) 🔗

Adds text span and font to draw it.


void clear() 🔗

Clears text line (removes text and inline objects).


void draw(canvas: RID, pos: Vector2, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const 🔗

Draw text into a canvas item at a given position, with color. pos specifies the top left corner of the bounding box. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.


void draw_outline(canvas: RID, pos: Vector2, outline_size: int = 1, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const 🔗

Draw text into a canvas item at a given position, with color. pos specifies the top left corner of the bounding box. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.


TextLine duplicate() const 🔗

Duplicates this TextLine.


Direction get_inferred_direction() const 🔗

Returns the text writing direction inferred by the BiDi algorithm.


float get_line_ascent() const 🔗

Returns the text ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical).


float get_line_descent() const 🔗

Returns the text descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical).


float get_line_underline_position() const 🔗

Returns pixel offset of the underline below the baseline.


float get_line_underline_thickness() const 🔗

Returns thickness of the underline.


float get_line_width() const 🔗

Returns width (for horizontal layout) or height (for vertical) of the text.


Rect2 get_object_rect(key: Variant) const 🔗

Returns bounding rectangle of the inline object.


Array get_objects() const 🔗

Returns array of inline objects.


RID get_rid() const 🔗

Renvoie le RID de buffer du TextServer.


Vector2 get_size() const 🔗

Returns size of the bounding box of the text.


bool has_object(key: Variant) const 🔗

Returns true if an object with key is embedded in this line.


int hit_test(coords: float) const 🔗

Returns caret character offset at the specified pixel offset at the baseline. This function always returns a valid position.


bool resize_object(key: Variant, size: Vector2, inline_align: InlineAlignment = 5, baseline: float = 0.0) 🔗

Définit la nouvelle taille et alignement de l'objet intégré.


void set_bidi_override(override: Array) 🔗

Redéfinit la BiDi pour le texte structuré.

Les plages de redéfinition devraient couvrir le texte source complet sans chevauchements. L'algorithme BiDi sera utilisé sur chaque plage séparément.


void tab_align(tab_stops: PackedFloat32Array) 🔗

Aligns text to the given tab-stops.