Index · Object → RefCounted → TextLine

TextLine

Holds a line of text.

Class Description

Abstraction over TextServer for handling a single line of text.

Properties

var alignment: HorizontalAlignment = 0

Sets text alignment within the line as if the line was horizontal.

var direction: TextServer.Direction = 0

Text writing direction.

var ellipsis_char: String = "…"

Ellipsis character used for text clipping.

var flags: TextServer.JustificationFlag = 3

Line alignment rules. For more info see TextServer.

var orientation: TextServer.Orientation = 0

Text orientation.

var preserve_control: bool = false

If set to true text will display control characters.

var preserve_invalid: bool = true

If set to true text will display invalid characters.

var text_overrun_behavior: TextServer.OverrunBehavior = 3

The clipping behavior when the text exceeds the text line's set width.

var width: float = -1.0

Text line width.

Methods

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

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

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

Adds text span and font to draw it.

func clear() -> void

Clears text line (removes text and inline objects).

func draw(canvas: RID, pos: Vector2, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) -> void

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.

func draw_outline(canvas: RID, pos: Vector2, outline_size: int = 1, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) -> void

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.

func duplicate() -> TextLine

Duplicates this TextLine.

func get_inferred_direction() -> TextServer.Direction

Returns the text writing direction inferred by the BiDi algorithm.

func get_line_ascent() -> float

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

func get_line_descent() -> float

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

func get_line_underline_position() -> float

Returns pixel offset of the underline below the baseline.

func get_line_underline_thickness() -> float

Returns thickness of the underline.

func get_line_width() -> float

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

func get_object_rect(key: Variant) -> Rect2

Returns bounding rectangle of the inline object.

func get_objects() -> Array

Returns array of inline objects.

func get_rid() -> RID

Returns TextServer buffer RID.

func get_size() -> Vector2

Returns size of the bounding box of the text.

func has_object(key: Variant) -> bool

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

func hit_test(coords: float) -> int

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

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

Sets new size and alignment of embedded object.

func set_bidi_override(override: Array) -> void

Overrides BiDi for the structured text.

Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately.

func tab_align(tab_stops: PackedFloat32Array) -> void

Aligns text to the given tab-stops.

Inherited from RefCounted (4)
func init_ref() -> bool
func reference() -> bool
func unreference() -> bool
Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

Inherited from Object (2)