Up to date

This page is up to date for Godot 4.0. If you still find outdated information, please open an issue.

TextServerยถ

Inherits: RefCounted < Object

Inherited By: TextServerExtension

A server interface for font management and text rendering.

Descriptionยถ

TextServer is the API backend for managing fonts and rendering text.

Methodsยถ

RID

create_font ( )

RID

create_shaped_text ( Direction direction=0, Orientation orientation=0 )

void

draw_hex_code_box ( RID canvas, int size, Vector2 pos, int index, Color color ) const

void

font_clear_glyphs ( RID font_rid, Vector2i size )

void

font_clear_kerning_map ( RID font_rid, int size )

void

font_clear_size_cache ( RID font_rid )

void

font_clear_textures ( RID font_rid, Vector2i size )

void

font_draw_glyph ( RID font_rid, RID canvas, int size, Vector2 pos, int index, Color color=Color(1, 1, 1, 1) ) const

void

font_draw_glyph_outline ( RID font_rid, RID canvas, int size, int outline_size, Vector2 pos, int index, Color color=Color(1, 1, 1, 1) ) const

FontAntialiasing

font_get_antialiasing ( RID font_rid ) const

float

font_get_ascent ( RID font_rid, int size ) const

float

font_get_descent ( RID font_rid, int size ) const

float

font_get_embolden ( RID font_rid ) const

int

font_get_face_count ( RID font_rid ) const

int

font_get_face_index ( RID font_rid ) const

int

font_get_fixed_size ( RID font_rid ) const

bool

font_get_generate_mipmaps ( RID font_rid ) const

float

font_get_global_oversampling ( ) const

Vector2

font_get_glyph_advance ( RID font_rid, int size, int glyph ) const

Dictionary

font_get_glyph_contours ( RID font, int size, int index ) const

int

font_get_glyph_index ( RID font_rid, int size, int char, int variation_selector ) const

PackedInt32Array

font_get_glyph_list ( RID font_rid, Vector2i size ) const

Vector2

font_get_glyph_offset ( RID font_rid, Vector2i size, int glyph ) const

Vector2

font_get_glyph_size ( RID font_rid, Vector2i size, int glyph ) const

int

font_get_glyph_texture_idx ( RID font_rid, Vector2i size, int glyph ) const

RID

font_get_glyph_texture_rid ( RID font_rid, Vector2i size, int glyph ) const

Vector2

font_get_glyph_texture_size ( RID font_rid, Vector2i size, int glyph ) const

Rect2

font_get_glyph_uv_rect ( RID font_rid, Vector2i size, int glyph ) const

Hinting

font_get_hinting ( RID font_rid ) const

Vector2

font_get_kerning ( RID font_rid, int size, Vector2i glyph_pair ) const

Vector2i[]

font_get_kerning_list ( RID font_rid, int size ) const

bool

font_get_language_support_override ( RID font_rid, String language )

PackedStringArray

font_get_language_support_overrides ( RID font_rid )

int

font_get_msdf_pixel_range ( RID font_rid ) const

int

font_get_msdf_size ( RID font_rid ) const

String

font_get_name ( RID font_rid ) const

Dictionary

font_get_opentype_feature_overrides ( RID font_rid ) const

float

font_get_oversampling ( RID font_rid ) const

float

font_get_scale ( RID font_rid, int size ) const

bool

font_get_script_support_override ( RID font_rid, String script )

PackedStringArray

font_get_script_support_overrides ( RID font_rid )

Vector2i[]

font_get_size_cache_list ( RID font_rid ) const

int

font_get_stretch ( RID font_rid ) const

FontStyle

font_get_style ( RID font_rid ) const

String

font_get_style_name ( RID font_rid ) const

SubpixelPositioning

font_get_subpixel_positioning ( RID font_rid ) const

String

font_get_supported_chars ( RID font_rid ) const

int

font_get_texture_count ( RID font_rid, Vector2i size ) const

Image

font_get_texture_image ( RID font_rid, Vector2i size, int texture_index ) const

PackedInt32Array

font_get_texture_offsets ( RID font_rid, Vector2i size, int texture_index ) const

Transform2D

font_get_transform ( RID font_rid ) const

float

font_get_underline_position ( RID font_rid, int size ) const

float

font_get_underline_thickness ( RID font_rid, int size ) const

Dictionary

font_get_variation_coordinates ( RID font_rid ) const

int

font_get_weight ( RID font_rid ) const

bool

font_has_char ( RID font_rid, int char ) const

bool

font_is_allow_system_fallback ( RID font_rid ) const

bool

font_is_force_autohinter ( RID font_rid ) const

bool

font_is_language_supported ( RID font_rid, String language ) const

bool

font_is_multichannel_signed_distance_field ( RID font_rid ) const

bool

font_is_script_supported ( RID font_rid, String script ) const

void

font_remove_glyph ( RID font_rid, Vector2i size, int glyph )

void

font_remove_kerning ( RID font_rid, int size, Vector2i glyph_pair )

void

font_remove_language_support_override ( RID font_rid, String language )

void

font_remove_script_support_override ( RID font_rid, String script )

void

font_remove_size_cache ( RID font_rid, Vector2i size )

void

font_remove_texture ( RID font_rid, Vector2i size, int texture_index )

void

font_render_glyph ( RID font_rid, Vector2i size, int index )

void

font_render_range ( RID font_rid, Vector2i size, int start, int end )

void

font_set_allow_system_fallback ( RID font_rid, bool allow_system_fallback )

void

font_set_antialiasing ( RID font_rid, FontAntialiasing antialiasing )

void

font_set_ascent ( RID font_rid, int size, float ascent )

void

font_set_data ( RID font_rid, PackedByteArray data )

void

font_set_descent ( RID font_rid, int size, float descent )

void

font_set_embolden ( RID font_rid, float strength )

void

font_set_face_index ( RID font_rid, int face_index )

void

font_set_fixed_size ( RID font_rid, int fixed_size )

void

font_set_force_autohinter ( RID font_rid, bool force_autohinter )

void

font_set_generate_mipmaps ( RID font_rid, bool generate_mipmaps )

void

font_set_global_oversampling ( float oversampling )

void

font_set_glyph_advance ( RID font_rid, int size, int glyph, Vector2 advance )

void

font_set_glyph_offset ( RID font_rid, Vector2i size, int glyph, Vector2 offset )

void

font_set_glyph_size ( RID font_rid, Vector2i size, int glyph, Vector2 gl_size )

void

font_set_glyph_texture_idx ( RID font_rid, Vector2i size, int glyph, int texture_idx )

void

font_set_glyph_uv_rect ( RID font_rid, Vector2i size, int glyph, Rect2 uv_rect )

void

font_set_hinting ( RID font_rid, Hinting hinting )

void

font_set_kerning ( RID font_rid, int size, Vector2i glyph_pair, Vector2 kerning )

void

font_set_language_support_override ( RID font_rid, String language, bool supported )

void

font_set_msdf_pixel_range ( RID font_rid, int msdf_pixel_range )

void

font_set_msdf_size ( RID font_rid, int msdf_size )

void

font_set_multichannel_signed_distance_field ( RID font_rid, bool msdf )

void

font_set_name ( RID font_rid, String name )

void

font_set_opentype_feature_overrides ( RID font_rid, Dictionary overrides )

void

font_set_oversampling ( RID font_rid, float oversampling )

void

font_set_scale ( RID font_rid, int size, float scale )

void

font_set_script_support_override ( RID font_rid, String script, bool supported )

void

font_set_stretch ( RID font_rid, int weight )

void

font_set_style ( RID font_rid, FontStyle style )

void

font_set_style_name ( RID font_rid, String name )

void

font_set_subpixel_positioning ( RID font_rid, SubpixelPositioning subpixel_positioning )

void

font_set_texture_image ( RID font_rid, Vector2i size, int texture_index, Image image )

void

font_set_texture_offsets ( RID font_rid, Vector2i size, int texture_index, PackedInt32Array offset )

void

font_set_transform ( RID font_rid, Transform2D transform )

void

font_set_underline_position ( RID font_rid, int size, float underline_position )

void

font_set_underline_thickness ( RID font_rid, int size, float underline_thickness )

void

font_set_variation_coordinates ( RID font_rid, Dictionary variation_coordinates )

void

font_set_weight ( RID font_rid, int weight )

Dictionary

font_supported_feature_list ( RID font_rid ) const

Dictionary

font_supported_variation_list ( RID font_rid ) const

String

format_number ( String number, String language="" ) const

void

free_rid ( RID rid )

int

get_features ( ) const

Vector2

get_hex_code_box_size ( int size, int index ) const

String

get_name ( ) const

String

get_support_data_filename ( ) const

String

get_support_data_info ( ) const

bool

has ( RID rid )

bool

has_feature ( Feature feature ) const

int

is_confusable ( String string, PackedStringArray dict ) const

bool

is_locale_right_to_left ( String locale ) const

bool

is_valid_identifier ( String string ) const

bool

load_support_data ( String filename )

int

name_to_tag ( String name ) const

String

parse_number ( String number, String language="" ) const

Vector3i[]

parse_structured_text ( StructuredTextParser parser_type, Array args, String text ) const

String

percent_sign ( String language="" ) const

bool

save_support_data ( String filename ) const

int

shaped_get_span_count ( RID shaped ) const

Variant

shaped_get_span_meta ( RID shaped, int index ) const

void

shaped_set_span_update_font ( RID shaped, int index, RID[] fonts, int size, Dictionary opentype_features={} )

bool

shaped_text_add_object ( RID shaped, Variant key, Vector2 size, InlineAlignment inline_align=5, int length=1, float baseline=0.0 )

bool

shaped_text_add_string ( RID shaped, String text, RID[] fonts, int size, Dictionary opentype_features={}, String language="", Variant meta=null )

void

shaped_text_clear ( RID rid )

void

shaped_text_draw ( RID shaped, RID canvas, Vector2 pos, float clip_l=-1, float clip_r=-1, Color color=Color(1, 1, 1, 1) ) const

void

shaped_text_draw_outline ( RID shaped, RID canvas, Vector2 pos, float clip_l=-1, float clip_r=-1, int outline_size=1, Color color=Color(1, 1, 1, 1) ) const

float

shaped_text_fit_to_width ( RID shaped, float width, JustificationFlag jst_flags=3 )

float

shaped_text_get_ascent ( RID shaped ) const

Dictionary

shaped_text_get_carets ( RID shaped, int position ) const

String

shaped_text_get_custom_punctuation ( RID shaped ) const

float

shaped_text_get_descent ( RID shaped ) const

Direction

shaped_text_get_direction ( RID shaped ) const

Direction

shaped_text_get_dominant_direction_in_range ( RID shaped, int start, int end ) const

int

shaped_text_get_ellipsis_glyph_count ( RID shaped ) const

Dictionary[]

shaped_text_get_ellipsis_glyphs ( RID shaped ) const

int

shaped_text_get_ellipsis_pos ( RID shaped ) const

int

shaped_text_get_glyph_count ( RID shaped ) const

Dictionary[]

shaped_text_get_glyphs ( RID shaped ) const

Vector2

shaped_text_get_grapheme_bounds ( RID shaped, int pos ) const

Direction

shaped_text_get_inferred_direction ( RID shaped ) const

PackedInt32Array

shaped_text_get_line_breaks ( RID shaped, float width, int start=0, LineBreakFlag break_flags=3 ) const

PackedInt32Array

shaped_text_get_line_breaks_adv ( RID shaped, PackedFloat32Array width, int start=0, bool once=true, LineBreakFlag break_flags=3 ) const

Rect2

shaped_text_get_object_rect ( RID shaped, Variant key ) const

Array

shaped_text_get_objects ( RID shaped ) const

Orientation

shaped_text_get_orientation ( RID shaped ) const

RID

shaped_text_get_parent ( RID shaped ) const

bool

shaped_text_get_preserve_control ( RID shaped ) const

bool

shaped_text_get_preserve_invalid ( RID shaped ) const

Vector2i

shaped_text_get_range ( RID shaped ) const

PackedVector2Array

shaped_text_get_selection ( RID shaped, int start, int end ) const

Vector2

shaped_text_get_size ( RID shaped ) const

int

shaped_text_get_spacing ( RID shaped, SpacingType spacing ) const

int

shaped_text_get_trim_pos ( RID shaped ) const

float

shaped_text_get_underline_position ( RID shaped ) const

float

shaped_text_get_underline_thickness ( RID shaped ) const

float

shaped_text_get_width ( RID shaped ) const

PackedInt32Array

shaped_text_get_word_breaks ( RID shaped, GraphemeFlag grapheme_flags=264 ) const

int

shaped_text_hit_test_grapheme ( RID shaped, float coords ) const

int

shaped_text_hit_test_position ( RID shaped, float coords ) const

bool

shaped_text_is_ready ( RID shaped ) const

int

shaped_text_next_grapheme_pos ( RID shaped, int pos ) const

void

shaped_text_overrun_trim_to_width ( RID shaped, float width=0, TextOverrunFlag overrun_trim_flags=0 )

int

shaped_text_prev_grapheme_pos ( RID shaped, int pos ) const

bool

shaped_text_resize_object ( RID shaped, Variant key, Vector2 size, InlineAlignment inline_align=5, float baseline=0.0 )

void

shaped_text_set_bidi_override ( RID shaped, Array override )

void

shaped_text_set_custom_punctuation ( RID shaped, String punct )

void

shaped_text_set_direction ( RID shaped, Direction direction=0 )

void

shaped_text_set_orientation ( RID shaped, Orientation orientation=0 )

void

shaped_text_set_preserve_control ( RID shaped, bool enabled )

void

shaped_text_set_preserve_invalid ( RID shaped, bool enabled )

void

shaped_text_set_spacing ( RID shaped, SpacingType spacing, int value )

bool

shaped_text_shape ( RID shaped )

Dictionary[]

shaped_text_sort_logical ( RID shaped )

RID

shaped_text_substr ( RID shaped, int start, int length ) const

float

shaped_text_tab_align ( RID shaped, PackedFloat32Array tab_stops )

bool

spoof_check ( String string ) const

PackedInt32Array

string_get_word_breaks ( String string, String language="", int chars_per_line=0 ) const

String

string_to_lower ( String string, String language="" ) const

String

string_to_upper ( String string, String language="" ) const

String

strip_diacritics ( String string ) const

String

tag_to_name ( int tag ) const


Enumerationsยถ

enum FontAntialiasing:

FontAntialiasing FONT_ANTIALIASING_NONE = 0

Font glyphs are rasterized as 1-bit bitmaps.

FontAntialiasing FONT_ANTIALIASING_GRAY = 1

Font glyphs are rasterized as 8-bit grayscale anti-aliased bitmaps.

FontAntialiasing FONT_ANTIALIASING_LCD = 2

Font glyphs are rasterized for LCD screens.

LCD subpixel layout is determined by the value of gui/theme/lcd_subpixel_layout project settings.

LCD subpixel anti-aliasing mode is suitable only for rendering horizontal, unscaled text in 2D.


enum FontLCDSubpixelLayout:

FontLCDSubpixelLayout FONT_LCD_SUBPIXEL_LAYOUT_NONE = 0

Unknown or unsupported subpixel layout, LCD subpixel antialiasing is disabled.

FontLCDSubpixelLayout FONT_LCD_SUBPIXEL_LAYOUT_HRGB = 1

Horizontal RGB subpixel layout.

FontLCDSubpixelLayout FONT_LCD_SUBPIXEL_LAYOUT_HBGR = 2

Horizontal BGR subpixel layout.

FontLCDSubpixelLayout FONT_LCD_SUBPIXEL_LAYOUT_VRGB = 3

Vertical RGB subpixel layout.

FontLCDSubpixelLayout FONT_LCD_SUBPIXEL_LAYOUT_VBGR = 4

Vertical BGR subpixel layout.

FontLCDSubpixelLayout FONT_LCD_SUBPIXEL_LAYOUT_MAX = 5


enum Direction:

Direction DIRECTION_AUTO = 0

Text direction is determined based on contents and current locale.

Direction DIRECTION_LTR = 1

Text is written from left to right.

Direction DIRECTION_RTL = 2

Text is written from right to left.

Direction DIRECTION_INHERITED = 3

Text writing direction is the same as base string writing direction. Used for BiDi override only.


enum Orientation:

Orientation ORIENTATION_HORIZONTAL = 0

Text is written horizontally.

Orientation ORIENTATION_VERTICAL = 1

Left to right text is written vertically from top to bottom.

Right to left text is written vertically from bottom to top.


flags JustificationFlag:

JustificationFlag JUSTIFICATION_NONE = 0

Do not justify text.

JustificationFlag JUSTIFICATION_KASHIDA = 1

Justify text by adding and removing kashidas.

JustificationFlag JUSTIFICATION_WORD_BOUND = 2

Justify text by changing width of the spaces between the words.

JustificationFlag JUSTIFICATION_TRIM_EDGE_SPACES = 4

Remove trailing and leading spaces from the justified text.

JustificationFlag JUSTIFICATION_AFTER_LAST_TAB = 8

Only apply justification to the part of the text after the last tab.

JustificationFlag JUSTIFICATION_CONSTRAIN_ELLIPSIS = 16

Apply justification to the trimmed line with ellipsis.


enum AutowrapMode:

AutowrapMode AUTOWRAP_OFF = 0

Autowrap is disabled.

AutowrapMode AUTOWRAP_ARBITRARY = 1

Wraps the text inside the node's bounding rectangle by allowing to break lines at arbitrary positions, which is useful when very limited space is available.

AutowrapMode AUTOWRAP_WORD = 2

Wraps the text inside the node's bounding rectangle by soft-breaking between words.

AutowrapMode AUTOWRAP_WORD_SMART = 3

Behaves similarly to AUTOWRAP_WORD, but force-breaks a word if that single word does not fit in one line.


flags LineBreakFlag:

LineBreakFlag BREAK_NONE = 0

Do not break the line.

LineBreakFlag BREAK_MANDATORY = 1

Break the line at the line mandatory break characters (e.g. "\n").

LineBreakFlag BREAK_WORD_BOUND = 2

Break the line between the words.

LineBreakFlag BREAK_GRAPHEME_BOUND = 4

Break the line between any unconnected graphemes.

LineBreakFlag BREAK_ADAPTIVE = 8

Should be used only in conjunction with BREAK_WORD_BOUND, break the line between any unconnected graphemes, if it's impossible to break it between the words.

LineBreakFlag BREAK_TRIM_EDGE_SPACES = 16

Remove edge spaces from the broken line segments.


enum VisibleCharactersBehavior:

VisibleCharactersBehavior VC_CHARS_BEFORE_SHAPING = 0

Trims text before the shaping. e.g, increasing Label.visible_characters or RichTextLabel.visible_characters value is visually identical to typing the text.

VisibleCharactersBehavior VC_CHARS_AFTER_SHAPING = 1

Displays glyphs that are mapped to the first Label.visible_characters or RichTextLabel.visible_characters characters from the beginning of the text.

VisibleCharactersBehavior VC_GLYPHS_AUTO = 2

Displays Label.visible_ratio or RichTextLabel.visible_ratio glyphs, starting from the left or from the right, depending on Control.layout_direction value.

VisibleCharactersBehavior VC_GLYPHS_LTR = 3

Displays Label.visible_ratio or RichTextLabel.visible_ratio glyphs, starting from the left.

VisibleCharactersBehavior VC_GLYPHS_RTL = 4

Displays Label.visible_ratio or RichTextLabel.visible_ratio glyphs, starting from the right.


enum OverrunBehavior:

OverrunBehavior OVERRUN_NO_TRIMMING = 0

No text trimming is performed.

OverrunBehavior OVERRUN_TRIM_CHAR = 1

Trims the text per character.

OverrunBehavior OVERRUN_TRIM_WORD = 2

Trims the text per word.

OverrunBehavior OVERRUN_TRIM_ELLIPSIS = 3

Trims the text per character and adds an ellipsis to indicate that parts are hidden.

OverrunBehavior OVERRUN_TRIM_WORD_ELLIPSIS = 4

Trims the text per word and adds an ellipsis to indicate that parts are hidden.


flags TextOverrunFlag:

TextOverrunFlag OVERRUN_NO_TRIM = 0

No trimming is performed.

TextOverrunFlag OVERRUN_TRIM = 1

Trims the text when it exceeds the given width.

TextOverrunFlag OVERRUN_TRIM_WORD_ONLY = 2

Trims the text per word instead of per grapheme.

TextOverrunFlag OVERRUN_ADD_ELLIPSIS = 4

Determines whether an ellipsis should be added at the end of the text.

TextOverrunFlag OVERRUN_ENFORCE_ELLIPSIS = 8

Determines whether the ellipsis at the end of the text is enforced and may not be hidden.

TextOverrunFlag OVERRUN_JUSTIFICATION_AWARE = 16


flags GraphemeFlag:

GraphemeFlag GRAPHEME_IS_VALID = 1

Grapheme is supported by the font, and can be drawn.

GraphemeFlag GRAPHEME_IS_RTL = 2

Grapheme is part of right-to-left or bottom-to-top run.

GraphemeFlag GRAPHEME_IS_VIRTUAL = 4

Grapheme is not part of source text, it was added by justification process.

GraphemeFlag GRAPHEME_IS_SPACE = 8

Grapheme is whitespace.

GraphemeFlag GRAPHEME_IS_BREAK_HARD = 16

Grapheme is mandatory break point (e.g. "\n").

GraphemeFlag GRAPHEME_IS_BREAK_SOFT = 32

Grapheme is optional break point (e.g. space).

GraphemeFlag GRAPHEME_IS_TAB = 64

Grapheme is the tabulation character.

GraphemeFlag GRAPHEME_IS_ELONGATION = 128

Grapheme is kashida.

GraphemeFlag GRAPHEME_IS_PUNCTUATION = 256

Grapheme is punctuation character.

GraphemeFlag GRAPHEME_IS_UNDERSCORE = 512

Grapheme is underscore character.

GraphemeFlag GRAPHEME_IS_CONNECTED = 1024

Grapheme is connected to the previous grapheme. Breaking line before this grapheme is not safe.

GraphemeFlag GRAPHEME_IS_SAFE_TO_INSERT_TATWEEL = 2048

It is safe to insert a U+0640 before this grapheme for elongation.

GraphemeFlag GRAPHEME_IS_EMBEDDED_OBJECT = 4096

Grapheme is an object replacement character for the embedded object.


enum Hinting:

Hinting HINTING_NONE = 0

Disables font hinting (smoother but less crisp).

Hinting HINTING_LIGHT = 1

Use the light font hinting mode.

Hinting HINTING_NORMAL = 2

Use the default font hinting mode (crisper but less smooth).

Note: This hinting mode changes both horizontal and vertical glyph metrics. If applied to monospace font, some glyphs might have different width.


enum SubpixelPositioning:

SubpixelPositioning SUBPIXEL_POSITIONING_DISABLED = 0

Glyph horizontal position is rounded to the whole pixel size, each glyph is rasterized once.

SubpixelPositioning SUBPIXEL_POSITIONING_AUTO = 1

Glyph horizontal position is rounded based on font size.

SubpixelPositioning SUBPIXEL_POSITIONING_ONE_HALF = 2

Glyph horizontal position is rounded to one half of the pixel size, each glyph is rasterized up to two times.

SubpixelPositioning SUBPIXEL_POSITIONING_ONE_QUARTER = 3

Glyph horizontal position is rounded to one quarter of the pixel size, each glyph is rasterized up to four times.

SubpixelPositioning SUBPIXEL_POSITIONING_ONE_HALF_MAX_SIZE = 20

Maximum font size which will use one half of the pixel subpixel positioning in SUBPIXEL_POSITIONING_AUTO mode.

SubpixelPositioning SUBPIXEL_POSITIONING_ONE_QUARTER_MAX_SIZE = 16

Maximum font size which will use one quarter of the pixel subpixel positioning in SUBPIXEL_POSITIONING_AUTO mode.


enum Feature:

Feature FEATURE_SIMPLE_LAYOUT = 1

TextServer supports simple text layouts.

Feature FEATURE_BIDI_LAYOUT = 2

TextServer supports bidirectional text layouts.

Feature FEATURE_VERTICAL_LAYOUT = 4

TextServer supports vertical layouts.

Feature FEATURE_SHAPING = 8

TextServer supports complex text shaping.

Feature FEATURE_KASHIDA_JUSTIFICATION = 16

TextServer supports justification using kashidas.

Feature FEATURE_BREAK_ITERATORS = 32

TextServer supports complex line/word breaking rules (e.g. dictionary based).

Feature FEATURE_FONT_BITMAP = 64

TextServer supports loading bitmap fonts.

Feature FEATURE_FONT_DYNAMIC = 128

TextServer supports loading dynamic (TrueType, OpeType, etc.) fonts.

Feature FEATURE_FONT_MSDF = 256

TextServer supports multichannel signed distance field dynamic font rendering.

Feature FEATURE_FONT_SYSTEM = 512

TextServer supports loading system fonts.

Feature FEATURE_FONT_VARIABLE = 1024

TextServer supports variable fonts.

Feature FEATURE_CONTEXT_SENSITIVE_CASE_CONVERSION = 2048

TextServer supports locale dependent and context sensitive case conversion.

Feature FEATURE_USE_SUPPORT_DATA = 4096

TextServer require external data file for some features, see load_support_data.

Feature FEATURE_UNICODE_IDENTIFIERS = 8192

TextServer supports UAX #31 identifier validation, see is_valid_identifier.

Feature FEATURE_UNICODE_SECURITY = 16384

TextServer supports Unicode Technical Report #36 and Unicode Technical Standard #39 based spoof detection features.


enum ContourPointTag:

ContourPointTag CONTOUR_CURVE_TAG_ON = 1

Contour point is on the curve.

ContourPointTag CONTOUR_CURVE_TAG_OFF_CONIC = 0

Contour point isn't on the curve, but serves as a control point for a conic (quadratic) Bรฉzier arc.

ContourPointTag CONTOUR_CURVE_TAG_OFF_CUBIC = 2

Contour point isn't on the curve, but serves as a control point for a cubic Bรฉzier arc.


enum SpacingType:

SpacingType SPACING_GLYPH = 0

Spacing for each glyph.

SpacingType SPACING_SPACE = 1

Spacing for the space character.

SpacingType SPACING_TOP = 2

Spacing at the top of the line.

SpacingType SPACING_BOTTOM = 3

Spacing at the bottom of the line.

SpacingType SPACING_MAX = 4


flags FontStyle:

FontStyle FONT_BOLD = 1

Font is bold.

FontStyle FONT_ITALIC = 2

Font is italic or oblique.

FontStyle FONT_FIXED_WIDTH = 4

Font have fixed-width characters.


enum StructuredTextParser:

StructuredTextParser STRUCTURED_TEXT_DEFAULT = 0

Use default Unicode BiDi algorithm.

StructuredTextParser STRUCTURED_TEXT_URI = 1

BiDi override for URI.

StructuredTextParser STRUCTURED_TEXT_FILE = 2

BiDi override for file path.

StructuredTextParser STRUCTURED_TEXT_EMAIL = 3

BiDi override for email.

StructuredTextParser STRUCTURED_TEXT_LIST = 4

BiDi override for lists.

Structured text options: list separator String.

StructuredTextParser STRUCTURED_TEXT_GDSCRIPT = 5

BiDi override for GDScript.

StructuredTextParser STRUCTURED_TEXT_CUSTOM = 6

User defined structured text BiDi override function.


Method Descriptionsยถ

RID create_font ( )

Creates a new, empty font cache entry resource. To free the resulting resource, use the free_rid method.


RID create_shaped_text ( Direction direction=0, Orientation orientation=0 )

Creates new buffer for complex text layout, with the given direction and orientation. To free the resulting buffer, use free_rid method.

Note: Direction is ignored if server does not support FEATURE_BIDI_LAYOUT feature (supported by TextServerAdvanced).

Note: Orientation is ignored if server does not support FEATURE_VERTICAL_LAYOUT feature (supported by TextServerAdvanced).


void draw_hex_code_box ( RID canvas, int size, Vector2 pos, int index, Color color ) const

Draws box displaying character hexadecimal code. Used for replacing missing characters.


void font_clear_glyphs ( RID font_rid, Vector2i size )

Removes all rendered glyphs information from the cache entry.

Note: This function will not remove textures associated with the glyphs, use font_remove_texture to remove them manually.


void font_clear_kerning_map ( RID font_rid, int size )

Removes all kerning overrides.


void font_clear_size_cache ( RID font_rid )

Removes all font sizes from the cache entry.


void font_clear_textures ( RID font_rid, Vector2i size )

Removes all textures from font cache entry.

Note: This function will not remove glyphs associated with the texture, use font_remove_glyph to remove them manually.


void font_draw_glyph ( RID font_rid, RID canvas, int size, Vector2 pos, int index, Color color=Color(1, 1, 1, 1) ) const

Draws single glyph into a canvas item at the position, using font_rid at the size size.

Note: Glyph index is specific to the font, use glyphs indices returned by shaped_text_get_glyphs or font_get_glyph_index.

Note: If there are pending glyphs to render, calling this function might trigger the texture cache update.


void font_draw_glyph_outline ( RID font_rid, RID canvas, int size, int outline_size, Vector2 pos, int index, Color color=Color(1, 1, 1, 1) ) const

Draws single glyph outline of size outline_size into a canvas item at the position, using font_rid at the size size.

Note: Glyph index is specific to the font, use glyphs indices returned by shaped_text_get_glyphs or font_get_glyph_index.

Note: If there are pending glyphs to render, calling this function might trigger the texture cache update.


FontAntialiasing font_get_antialiasing ( RID font_rid ) const

Returns font anti-aliasing mode.


float font_get_ascent ( RID font_rid, int size ) const

Returns the font ascent (number of pixels above the baseline).


float font_get_descent ( RID font_rid, int size ) const

Returns the font descent (number of pixels below the baseline).


float font_get_embolden ( RID font_rid ) const

Returns font embolden strength.


int font_get_face_count ( RID font_rid ) const

Returns number of faces in the TrueType / OpenType collection.


int font_get_face_index ( RID font_rid ) const

Recturns an active face index in the TrueType / OpenType collection.


int font_get_fixed_size ( RID font_rid ) const

Returns bitmap font fixed size.


bool font_get_generate_mipmaps ( RID font_rid ) const

Returns true if font texture mipmap generation is enabled.


float font_get_global_oversampling ( ) const

Returns the font oversampling factor, shared by all fonts in the TextServer.


Vector2 font_get_glyph_advance ( RID font_rid, int size, int glyph ) const

Returns glyph advance (offset of the next glyph).

Note: Advance for glyphs outlines is the same as the base glyph advance and is not saved.


Dictionary font_get_glyph_contours ( RID font, int size, int index ) const

Returns outline contours of the glyph as a Dictionary with the following contents:

points - PackedVector3Array, containing outline points. x and y are point coordinates. z is the type of the point, using the ContourPointTag values.

contours - PackedInt32Array, containing indices the end points of each contour.

orientation - bool, contour orientation. If true, clockwise contours must be filled.


int font_get_glyph_index ( RID font_rid, int size, int char, int variation_selector ) const

Returns the glyph index of a char, optionally modified by the variation_selector.


PackedInt32Array font_get_glyph_list ( RID font_rid, Vector2i size ) const

Returns list of rendered glyphs in the cache entry.


Vector2 font_get_glyph_offset ( RID font_rid, Vector2i size, int glyph ) const

Returns glyph offset from the baseline.


Vector2 font_get_glyph_size ( RID font_rid, Vector2i size, int glyph ) const

Returns size of the glyph.


int font_get_glyph_texture_idx ( RID font_rid, Vector2i size, int glyph ) const

Returns index of the cache texture containing the glyph.


RID font_get_glyph_texture_rid ( RID font_rid, Vector2i size, int glyph ) const

Returns resource ID of the cache texture containing the glyph.

Note: If there are pending glyphs to render, calling this function might trigger the texture cache update.


Vector2 font_get_glyph_texture_size ( RID font_rid, Vector2i size, int glyph ) const

Returns size of the cache texture containing the glyph.

Note: If there are pending glyphs to render, calling this function might trigger the texture cache update.


Rect2 font_get_glyph_uv_rect ( RID font_rid, Vector2i size, int glyph ) const

Returns rectangle in the cache texture containing the glyph.


Hinting font_get_hinting ( RID font_rid ) const

Returns the font hinting mode. Used by dynamic fonts only.


Vector2 font_get_kerning ( RID font_rid, int size, Vector2i glyph_pair ) const

Returns kerning for the pair of glyphs.


Vector2i[] font_get_kerning_list ( RID font_rid, int size ) const

Returns list of the kerning overrides.


bool font_get_language_support_override ( RID font_rid, String language )

Returns true if support override is enabled for the language.


PackedStringArray font_get_language_support_overrides ( RID font_rid )

Returns list of language support overrides.


int font_get_msdf_pixel_range ( RID font_rid ) const

Returns the width of the range around the shape between the minimum and maximum representable signed distance.


int font_get_msdf_size ( RID font_rid ) const

Returns source font size used to generate MSDF textures.


String font_get_name ( RID font_rid ) const

Returns font family name.


Dictionary font_get_opentype_feature_overrides ( RID font_rid ) const

Returns font OpenType feature set override.


float font_get_oversampling ( RID font_rid ) const

Returns font oversampling factor, if set to 0.0 global oversampling factor is used instead. Used by dynamic fonts only.


float font_get_scale ( RID font_rid, int size ) const

Returns scaling factor of the color bitmap font.


bool font_get_script_support_override ( RID font_rid, String script )

Returns true if support override is enabled for the script.


PackedStringArray font_get_script_support_overrides ( RID font_rid )

Returns list of script support overrides.


Vector2i[] font_get_size_cache_list ( RID font_rid ) const

Returns list of the font sizes in the cache. Each size is Vector2i with font size and outline size.


int font_get_stretch ( RID font_rid ) const

Returns font stretch amount, compared to a normal width. A percentage value between 50% and 200%.


FontStyle font_get_style ( RID font_rid ) const

Returns font style flags, see FontStyle.


String font_get_style_name ( RID font_rid ) const

Returns font style name.


SubpixelPositioning font_get_subpixel_positioning ( RID font_rid ) const

Returns font subpixel glyph positioning mode.


String font_get_supported_chars ( RID font_rid ) const

Returns a string containing all the characters available in the font.


int font_get_texture_count ( RID font_rid, Vector2i size ) const

Returns number of textures used by font cache entry.


Image font_get_texture_image ( RID font_rid, Vector2i size, int texture_index ) const

Returns font cache texture image data.


PackedInt32Array font_get_texture_offsets ( RID font_rid, Vector2i size, int texture_index ) const

Returns array containing glyph packing data.


Transform2D font_get_transform ( RID font_rid ) const

Returns 2D transform applied to the font outlines.


float font_get_underline_position ( RID font_rid, int size ) const

Returns pixel offset of the underline below the baseline.


float font_get_underline_thickness ( RID font_rid, int size ) const

Returns thickness of the underline in pixels.


Dictionary font_get_variation_coordinates ( RID font_rid ) const

Returns variation coordinates for the specified font cache entry. See font_supported_variation_list for more info.


int font_get_weight ( RID font_rid ) const

Returns weight (boldness) of the font. A value in the 100...999 range, normal font weight is 400, bold font weight is 700.


bool font_has_char ( RID font_rid, int char ) const

Returns true if a Unicode char is available in the font.


bool font_is_allow_system_fallback ( RID font_rid ) const

Returns true if system fonts can be automatically used as fallbacks.


bool font_is_force_autohinter ( RID font_rid ) const

Returns true if auto-hinting is supported and preferred over font built-in hinting. Used by dynamic fonts only.


bool font_is_language_supported ( RID font_rid, String language ) const

Returns true, if font supports given language (ISO 639 code).


bool font_is_multichannel_signed_distance_field ( RID font_rid ) const

Returns true if glyphs of all sizes are rendered using single multichannel signed distance field generated from the dynamic font vector data.


bool font_is_script_supported ( RID font_rid, String script ) const

Returns true, if font supports given script (ISO 15924 code).


void font_remove_glyph ( RID font_rid, Vector2i size, int glyph )

Removes specified rendered glyph information from the cache entry.

Note: This function will not remove textures associated with the glyphs, use font_remove_texture to remove them manually.


void font_remove_kerning ( RID font_rid, int size, Vector2i glyph_pair )

Removes kerning override for the pair of glyphs.


void font_remove_language_support_override ( RID font_rid, String language )

Remove language support override.


void font_remove_script_support_override ( RID font_rid, String script )

Removes script support override.


void font_remove_size_cache ( RID font_rid, Vector2i size )

Removes specified font size from the cache entry.


void font_remove_texture ( RID font_rid, Vector2i size, int texture_index )

Removes specified texture from the cache entry.

Note: This function will not remove glyphs associated with the texture, remove them manually, using font_remove_glyph.


void font_render_glyph ( RID font_rid, Vector2i size, int index )

Renders specified glyph to the font cache texture.


void font_render_range ( RID font_rid, Vector2i size, int start, int end )

Renders the range of characters to the font cache texture.


void font_set_allow_system_fallback ( RID font_rid, bool allow_system_fallback )

If set to true, system fonts can be automatically used as fallbacks.


void font_set_antialiasing ( RID font_rid, FontAntialiasing antialiasing )

Sets font anti-aliasing mode.


void font_set_ascent ( RID font_rid, int size, float ascent )

Sets the font ascent (number of pixels above the baseline).


void font_set_data ( RID font_rid, PackedByteArray data )

Sets font source data, e.g contents of the dynamic font source file.


void font_set_descent ( RID font_rid, int size, float descent )

Sets the font descent (number of pixels below the baseline).


void font_set_embolden ( RID font_rid, float strength )

Sets font embolden strength. If strength is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.


void font_set_face_index ( RID font_rid, int face_index )

Sets an active face index in the TrueType / OpenType collection.


void font_set_fixed_size ( RID font_rid, int fixed_size )

Sets bitmap font fixed size. If set to value greater than zero, same cache entry will be used for all font sizes.


void font_set_force_autohinter ( RID font_rid, bool force_autohinter )

If set to true auto-hinting is preferred over font built-in hinting.


void font_set_generate_mipmaps ( RID font_rid, bool generate_mipmaps )

If set to true font texture mipmap generation is enabled.


void font_set_global_oversampling ( float oversampling )

Sets oversampling factor, shared by all font in the TextServer.

Note: This value can be automatically changed by display server.


void font_set_glyph_advance ( RID font_rid, int size, int glyph, Vector2 advance )

Sets glyph advance (offset of the next glyph).

Note: Advance for glyphs outlines is the same as the base glyph advance and is not saved.


void font_set_glyph_offset ( RID font_rid, Vector2i size, int glyph, Vector2 offset )

Sets glyph offset from the baseline.


void font_set_glyph_size ( RID font_rid, Vector2i size, int glyph, Vector2 gl_size )

Sets size of the glyph.


void font_set_glyph_texture_idx ( RID font_rid, Vector2i size, int glyph, int texture_idx )

Sets index of the cache texture containing the glyph.


void font_set_glyph_uv_rect ( RID font_rid, Vector2i size, int glyph, Rect2 uv_rect )

Sets rectangle in the cache texture containing the glyph.


void font_set_hinting ( RID font_rid, Hinting hinting )

Sets font hinting mode. Used by dynamic fonts only.


void font_set_kerning ( RID font_rid, int size, Vector2i glyph_pair, Vector2 kerning )

Sets kerning for the pair of glyphs.


void font_set_language_support_override ( RID font_rid, String language, bool supported )

Adds override for font_is_language_supported.


void font_set_msdf_pixel_range ( RID font_rid, int msdf_pixel_range )

Sets the width of the range around the shape between the minimum and maximum representable signed distance.


void font_set_msdf_size ( RID font_rid, int msdf_size )

Sets source font size used to generate MSDF textures.


void font_set_multichannel_signed_distance_field ( RID font_rid, bool msdf )

If set to true, glyphs of all sizes are rendered using single multichannel signed distance field generated from the dynamic font vector data. MSDF rendering allows displaying the font at any scaling factor without blurriness, and without incurring a CPU cost when the font size changes (since the font no longer needs to be rasterized on the CPU). As a downside, font hinting is not available with MSDF. The lack of font hinting may result in less crisp and less readable fonts at small sizes.

Note: MSDF font rendering does not render glyphs with overlapping shapes correctly. Overlapping shapes are not valid per the OpenType standard, but are still commonly found in many font files, especially those converted by Google Fonts. To avoid issues with overlapping glyphs, consider downloading the font file directly from the type foundry instead of relying on Google Fonts.


void font_set_name ( RID font_rid, String name )

Sets the font family name.


void font_set_opentype_feature_overrides ( RID font_rid, Dictionary overrides )

Sets font OpenType feature set override.


void font_set_oversampling ( RID font_rid, float oversampling )

Sets font oversampling factor, if set to 0.0 global oversampling factor is used instead. Used by dynamic fonts only.


void font_set_scale ( RID font_rid, int size, float scale )

Sets scaling factor of the color bitmap font.


void font_set_script_support_override ( RID font_rid, String script, bool supported )

Adds override for font_is_script_supported.


void font_set_stretch ( RID font_rid, int weight )

Sets font stretch amount, compared to a normal width. A percentage value between 50% and 200%.

Note: This value is used for font matching only and will not affect font rendering. Use font_set_face_index, font_set_variation_coordinates, or font_set_transform instead.


void font_set_style ( RID font_rid, FontStyle style )

Sets the font style flags, see FontStyle.

Note: This value is used for font matching only and will not affect font rendering. Use font_set_face_index, font_set_variation_coordinates, font_set_embolden, or font_set_transform instead.


void font_set_style_name ( RID font_rid, String name )

Sets the font style name.


void font_set_subpixel_positioning ( RID font_rid, SubpixelPositioning subpixel_positioning )

Sets font subpixel glyph positioning mode.


void font_set_texture_image ( RID font_rid, Vector2i size, int texture_index, Image image )

Sets font cache texture image data.


void font_set_texture_offsets ( RID font_rid, Vector2i size, int texture_index, PackedInt32Array offset )

Sets array containing glyph packing data.


void font_set_transform ( RID font_rid, Transform2D transform )

Sets 2D transform, applied to the font outlines, can be used for slanting, flipping and rotating glyphs.

For example, to simulate italic typeface by slanting, apply the following transform Transform2D(1.0, slant, 0.0, 1.0, 0.0, 0.0).


void font_set_underline_position ( RID font_rid, int size, float underline_position )

Sets pixel offset of the underline below the baseline.


void font_set_underline_thickness ( RID font_rid, int size, float underline_thickness )

Sets thickness of the underline in pixels.


void font_set_variation_coordinates ( RID font_rid, Dictionary variation_coordinates )

Sets variation coordinates for the specified font cache entry. See font_supported_variation_list for more info.


void font_set_weight ( RID font_rid, int weight )

Sets weight (boldness) of the font. A value in the 100...999 range, normal font weight is 400, bold font weight is 700.

Note: This value is used for font matching only and will not affect font rendering. Use font_set_face_index, font_set_variation_coordinates, or font_set_embolden instead.


Dictionary font_supported_feature_list ( RID font_rid ) const

Returns the dictionary of the supported OpenType features.


Dictionary font_supported_variation_list ( RID font_rid ) const

Returns the dictionary of the supported OpenType variation coordinates.


String format_number ( String number, String language="" ) const

Converts a number from the Western Arabic (0..9) to the numeral systems used in language.

If language is omitted, the active locale will be used.


void free_rid ( RID rid )

Frees an object created by this TextServer.


int get_features ( ) const

Returns text server features, see Feature.


Vector2 get_hex_code_box_size ( int size, int index ) const

Returns size of the replacement character (box with character hexadecimal code that is drawn in place of invalid characters).


String get_name ( ) const

Returns the name of the server interface.


String get_support_data_filename ( ) const

Returns default TextServer database (e.g. ICU break iterators and dictionaries) filename.


String get_support_data_info ( ) const

Returns TextServer database (e.g. ICU break iterators and dictionaries) description.


bool has ( RID rid )

Returns true if rid is valid resource owned by this text server.


bool has_feature ( Feature feature ) const

Returns true if the server supports a feature.


int is_confusable ( String string, PackedStringArray dict ) const

Returns index of the first string in dict which is visually confusable with the string, or -1 if none is found.

Note: This method doesn't detect invisible characters, for spoof detection use it in combination with spoof_check.

Note: Always returns -1 if the server does not support the FEATURE_UNICODE_SECURITY feature.


bool is_locale_right_to_left ( String locale ) const

Returns true if locale is right-to-left.


bool is_valid_identifier ( String string ) const

Returns true if string is a valid identifier.

If the text server supports the FEATURE_UNICODE_IDENTIFIERS feature, a valid identifier must:

  • Conform to normalization form C.

  • Begin with a Unicode character of class XID_Start or "_".

  • May contain Unicode characters of class XID_Continue in the other positions.

  • Use UAX #31 recommended scripts only (mixed scripts are allowed).

If the FEATURE_UNICODE_IDENTIFIERS feature is not supported, a valid identifier must:

  • Begin with a Unicode character of class XID_Start or "_".

  • May contain Unicode characters of class XID_Continue in the other positions.


bool load_support_data ( String filename )

Loads optional TextServer database (e.g. ICU break iterators and dictionaries).

Note: This function should be called before any other TextServer functions used, otherwise it won't have any effect.


int name_to_tag ( String name ) const

Converts readable feature, variation, script or language name to OpenType tag.


String parse_number ( String number, String language="" ) const

Converts number from the numeral systems used in language to Western Arabic (0..9).


Vector3i[] parse_structured_text ( StructuredTextParser parser_type, Array args, String text ) const

Default implementation of the BiDi algorithm override function. See StructuredTextParser for more info.


String percent_sign ( String language="" ) const

Returns percent sign used in the language.


bool save_support_data ( String filename ) const

Saves optional TextServer database (e.g. ICU break iterators and dictionaries) to the file.

Note: This function is used by during project export, to include TextServer database.


int shaped_get_span_count ( RID shaped ) const

Returns number of text spans added using shaped_text_add_string or shaped_text_add_object.


Variant shaped_get_span_meta ( RID shaped, int index ) const

Returns text span metadata.


void shaped_set_span_update_font ( RID shaped, int index, RID[] fonts, int size, Dictionary opentype_features={} )

Changes text span font, font size and OpenType features, without changing the text.


bool shaped_text_add_object ( RID shaped, Variant key, Vector2 size, InlineAlignment inline_align=5, int length=1, float baseline=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 shaped_text_add_string ( RID shaped, String text, RID[] fonts, int size, Dictionary opentype_features={}, String language="", Variant meta=null )

Adds text span and font to draw it to the text buffer.


void shaped_text_clear ( RID rid )

Clears text buffer (removes text and inline objects).


void shaped_text_draw ( RID shaped, RID canvas, Vector2 pos, float clip_l=-1, float clip_r=-1, Color color=Color(1, 1, 1, 1) ) const

Draw shaped text into a canvas item at a given position, with color. pos specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout).


void shaped_text_draw_outline ( RID shaped, RID canvas, Vector2 pos, float clip_l=-1, float clip_r=-1, int outline_size=1, Color color=Color(1, 1, 1, 1) ) const

Draw the outline of the shaped text into a canvas item at a given position, with color. pos specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout).


float shaped_text_fit_to_width ( RID shaped, float width, JustificationFlag jst_flags=3 )

Adjusts text width to fit to specified width, returns new text width.


float shaped_text_get_ascent ( RID shaped ) const

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

Note: Overall ascent can be higher than font ascent, if some glyphs are displaced from the baseline.


Dictionary shaped_text_get_carets ( RID shaped, int position ) const

Returns shapes of the carets corresponding to the character offset position in the text. Returned caret shape is 1 pixel wide rectangle.


String shaped_text_get_custom_punctuation ( RID shaped ) const

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


float shaped_text_get_descent ( RID shaped ) const

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

Note: Overall descent can be higher than font descent, if some glyphs are displaced from the baseline.


Direction shaped_text_get_direction ( RID shaped ) const

Returns direction of the text.


Direction shaped_text_get_dominant_direction_in_range ( RID shaped, int start, int end ) const

Returns dominant direction of in the range of text.


int shaped_text_get_ellipsis_glyph_count ( RID shaped ) const

Returns number of glyphs in the ellipsis.


Dictionary[] shaped_text_get_ellipsis_glyphs ( RID shaped ) const

Returns array of the glyphs in the ellipsis.


int shaped_text_get_ellipsis_pos ( RID shaped ) const

Returns position of the ellipsis.


int shaped_text_get_glyph_count ( RID shaped ) const

Returns number of glyphs in the buffer.


Dictionary[] shaped_text_get_glyphs ( RID shaped ) const

Returns an array of glyphs in the visual order.


Vector2 shaped_text_get_grapheme_bounds ( RID shaped, int pos ) const

Returns composite character's bounds as offsets from the start of the line.


Direction shaped_text_get_inferred_direction ( RID shaped ) const

Returns direction of the text, inferred by the BiDi algorithm.


PackedInt32Array shaped_text_get_line_breaks ( RID shaped, float width, int start=0, LineBreakFlag break_flags=3 ) const

Breaks text to the lines and returns character ranges for each line.


PackedInt32Array shaped_text_get_line_breaks_adv ( RID shaped, PackedFloat32Array width, int start=0, bool once=true, LineBreakFlag break_flags=3 ) const

Breaks text to the lines and columns. Returns character ranges for each segment.


Rect2 shaped_text_get_object_rect ( RID shaped, Variant key ) const

Returns bounding rectangle of the inline object.


Array shaped_text_get_objects ( RID shaped ) const

Returns array of inline objects.


Orientation shaped_text_get_orientation ( RID shaped ) const

Returns text orientation.


RID shaped_text_get_parent ( RID shaped ) const

Returns the parent buffer from which the substring originates.


bool shaped_text_get_preserve_control ( RID shaped ) const

Returns true if text buffer is configured to display control characters.


bool shaped_text_get_preserve_invalid ( RID shaped ) const

Returns true if text buffer is configured to display hexadecimal codes in place of invalid characters.

Note: If set to false, nothing is displayed in place of invalid characters.


Vector2i shaped_text_get_range ( RID shaped ) const

Returns substring buffer character range in the parent buffer.


PackedVector2Array shaped_text_get_selection ( RID shaped, int start, int end ) const

Returns selection rectangles for the specified character range.


Vector2 shaped_text_get_size ( RID shaped ) const

Returns size of the text.


int shaped_text_get_spacing ( RID shaped, SpacingType spacing ) const

Returns extra spacing added between glyphs or lines in pixels.


int shaped_text_get_trim_pos ( RID shaped ) const

Returns the position of the overrun trim.


float shaped_text_get_underline_position ( RID shaped ) const

Returns pixel offset of the underline below the baseline.


float shaped_text_get_underline_thickness ( RID shaped ) const

Returns thickness of the underline.


float shaped_text_get_width ( RID shaped ) const

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


PackedInt32Array shaped_text_get_word_breaks ( RID shaped, GraphemeFlag grapheme_flags=264 ) const

Breaks text into words and returns array of character ranges. Use grapheme_flags to set what characters are used for breaking (see GraphemeFlag).


int shaped_text_hit_test_grapheme ( RID shaped, float coords ) const

Returns grapheme index at the specified pixel offset at the baseline, or -1 if none is found.


int shaped_text_hit_test_position ( RID shaped, float coords ) const

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


bool shaped_text_is_ready ( RID shaped ) const

Returns true if buffer is successfully shaped.


int shaped_text_next_grapheme_pos ( RID shaped, int pos ) const

Returns composite character end position closest to the pos.


void shaped_text_overrun_trim_to_width ( RID shaped, float width=0, TextOverrunFlag overrun_trim_flags=0 )

Trims text if it exceeds the given width.


int shaped_text_prev_grapheme_pos ( RID shaped, int pos ) const

Returns composite character start position closest to the pos.


bool shaped_text_resize_object ( RID shaped, Variant key, Vector2 size, InlineAlignment inline_align=5, float baseline=0.0 )

Sets new size and alignment of embedded object.


void shaped_text_set_bidi_override ( RID shaped, Array override )

Overrides BiDi for the structured text.

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


void shaped_text_set_custom_punctuation ( RID shaped, String punct )

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


void shaped_text_set_direction ( RID shaped, Direction direction=0 )

Sets desired text direction. If set to DIRECTION_AUTO, direction will be detected based on the buffer contents and current locale.

Note: Direction is ignored if server does not support FEATURE_BIDI_LAYOUT feature (supported by TextServerAdvanced).


void shaped_text_set_orientation ( RID shaped, Orientation orientation=0 )

Sets desired text orientation.

Note: Orientation is ignored if server does not support FEATURE_VERTICAL_LAYOUT feature (supported by TextServerAdvanced).


void shaped_text_set_preserve_control ( RID shaped, bool enabled )

If set to true text buffer will display control characters.


void shaped_text_set_preserve_invalid ( RID shaped, bool enabled )

If set to true text buffer will display invalid characters as hexadecimal codes, otherwise nothing is displayed.


void shaped_text_set_spacing ( RID shaped, SpacingType spacing, int value )

Sets extra spacing added between glyphs or lines in pixels.


bool shaped_text_shape ( RID shaped )

Shapes buffer if it's not shaped. Returns true if the string is shaped successfully.

Note: It is not necessary to call this function manually, buffer will be shaped automatically as soon as any of its output data is requested.


Dictionary[] shaped_text_sort_logical ( RID shaped )

Returns text glyphs in the logical order.


RID shaped_text_substr ( RID shaped, int start, int length ) const

Returns text buffer for the substring of the text in the shaped text buffer (including inline objects).


float shaped_text_tab_align ( RID shaped, PackedFloat32Array tab_stops )

Aligns shaped text to the given tab-stops.


bool spoof_check ( String string ) const

Returns true if string is likely to be an attempt at confusing the reader.

Note: Always returns false if the server does not support the FEATURE_UNICODE_SECURITY feature.


PackedInt32Array string_get_word_breaks ( String string, String language="", int chars_per_line=0 ) const

Returns an array of the word break boundaries. Elements in the returned array are the offsets of the start and end of words. Therefore the length of the array is always even.

When chars_per_line is greater than zero, line break boundaries are returned instead.

var ts = TextServerManager.get_primary_interface()
print(ts.string_get_word_breaks("Godot Engine")) # Prints [0, 5, 6, 12]
print(ts.string_get_word_breaks("Godot Engine", "en", 5)) # Prints [0, 5, 6, 11, 11, 12]

String string_to_lower ( String string, String language="" ) const

Returns the string converted to lowercase.

Note: Casing is locale dependent and context sensitive if server support FEATURE_CONTEXT_SENSITIVE_CASE_CONVERSION feature (supported by TextServerAdvanced).

Note: The result may be longer or shorter than the original.


String string_to_upper ( String string, String language="" ) const

Returns the string converted to uppercase.

Note: Casing is locale dependent and context sensitive if server support FEATURE_CONTEXT_SENSITIVE_CASE_CONVERSION feature (supported by TextServerAdvanced).

Note: The result may be longer or shorter than the original.


String strip_diacritics ( String string ) const

Strips diacritics from the string.

Note: The result may be longer or shorter than the original.


String tag_to_name ( int tag ) const

Converts OpenType tag to readable feature, variation, script or language name.