Work in progress

Godot documentation is being updated to reflect the latest changes in version 4.0. Some documentation pages may still state outdated information. This banner will tell you if you're reading one of such pages.

The contents of this page are up to date. If you can still find outdated information, please open an issue.

TextServer

Inherits: RefCounted < Object

Inherited By: TextServerExtension

Interface for the fonts and complex text layouts.

Description

TextServer is the API backend for managing fonts, and rendering complex 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