Index · Object → RefCounted → TextParagraph

TextParagraph

Holds a paragraph of text.

Class Description

Abstraction over TextServer for handling a single paragraph of text.

Properties

var alignment: HorizontalAlignment = 0

Paragraph horizontal alignment.

var break_flags: TextServer.LineBreakFlag = 3

Line breaking rules. For more info see TextServer.

var custom_punctuation: String = ""

Custom punctuation character list, used for word breaking. If set to empty string, server defaults are used.

var direction: TextServer.Direction = 0

Text writing direction.

var ellipsis_char: String = "…"

Ellipsis character used for text clipping.

var justification_flags: TextServer.JustificationFlag = 163

Line fill alignment rules.

var line_spacing: float = 0.0

Additional vertical spacing between lines (in pixels), spacing is added to line descent. This value can be negative.

var max_lines_visible: int = -1

Limits the lines of text shown.

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 = 0

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

var width: float = -1.0

Paragraph 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 paragraph (removes text and inline objects).

func clear_dropcap() -> void

Removes dropcap.

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

Draw all lines of the text and drop cap 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_dropcap(canvas: RID, pos: Vector2, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) -> void

Draw drop cap 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_dropcap_outline(canvas: RID, pos: Vector2, outline_size: int = 1, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) -> void

Draw drop cap outline 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_line(canvas: RID, pos: Vector2, line: int, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) -> void

Draw single line of 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_line_outline(canvas: RID, pos: Vector2, line: int, outline_size: int = 1, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) -> void

Draw outline of the single line of 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), dc_color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) -> void

Draw outlines of all lines of the text and drop cap 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() -> TextParagraph

Duplicates this TextParagraph.

func get_dropcap_lines() -> int

Returns number of lines used by dropcap.

func get_dropcap_rid() -> RID

Returns drop cap text buffer RID.

func get_dropcap_size() -> Vector2

Returns drop cap bounding box size.

func get_inferred_direction() -> TextServer.Direction

Returns the text writing direction inferred by the BiDi algorithm.

func get_line_ascent(line: int) -> float

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

func get_line_count() -> int

Returns number of lines in the paragraph.

func get_line_descent(line: int) -> float

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

func get_line_object_rect(line: int, key: Variant) -> Rect2

Returns bounding rectangle of the inline object.

func get_line_objects(line: int) -> Array

Returns array of inline objects in the line.

func get_line_range(line: int) -> Vector2i

Returns character range of the line.

func get_line_rid(line: int) -> RID

Returns TextServer line buffer RID.

func get_line_size(line: int) -> Vector2

Returns size of the bounding box of the line of text. Returned size is rounded up.

func get_line_underline_position(line: int) -> float

Returns pixel offset of the underline below the baseline.

func get_line_underline_thickness(line: int) -> float

Returns thickness of the underline.

func get_line_width(line: int) -> float

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

func get_non_wrapped_size() -> Vector2

Returns the size of the bounding box of the paragraph, without line breaks.

func get_range() -> Vector2i

Returns the character range of the paragraph.

func get_rid() -> RID

Returns TextServer full string buffer RID.

func get_size() -> Vector2

Returns the size of the bounding box of the paragraph.

func has_object(key: Variant) -> bool

Returns true if an object with key is embedded in this shaped text buffer.

func hit_test(coords: Vector2) -> int

Returns caret character offset at the specified coordinates. 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 set_dropcap(text: String, font: Font, font_size: int, dropcap_margins: Rect2 = Rect2(0, 0, 0, 0), language: String = "") -> bool

Sets drop cap, overrides previously set drop cap. Drop cap (dropped capital) is a decorative element at the beginning of a paragraph that is larger than the rest of the text.

func tab_align(tab_stops: PackedFloat32Array) -> void

Aligns paragraph 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)