Table of Contents

Class TextServer

A server interface for font management and text rendering.

Inheritance
TextServer
Derived

Remarks

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

Note: This is a low-level API, consider using TextLine, TextParagraph, and Font classes instead.

This is an abstract class, so to get the currently active TextServer instance, use the following code:

var ts = TextServerManager.get_primary_interface()

Methods

create_font

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

RID create_font

create_font_linked_variation(RID)

Creates a new variation existing font which is reusing the same glyph cache and font data. To free the resulting resource, use the TextServer.free_rid method.

RID create_font_linked_variation(RID font_rid)

Parameters

font_rid RID

create_shaped_text(int, int)

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

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

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

RID create_shaped_text(int direction, int orientation)

Parameters

direction int
orientation int

draw_hex_code_box(RID, int, Vector2, int, Color)

Qualifiers: const

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

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

Parameters

canvas RID
size int
pos Vector2
index int
color Color

font_clear_glyphs(RID, Vector2i)

Removes all rendered glyph information from the cache entry.

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

void font_clear_glyphs(RID font_rid, Vector2i size)

Parameters

font_rid RID
size Vector2i

font_clear_kerning_map(RID, int)

Removes all kerning overrides.

void font_clear_kerning_map(RID font_rid, int size)

Parameters

font_rid RID
size int

font_clear_size_cache(RID)

Removes all font sizes from the cache entry.

void font_clear_size_cache(RID font_rid)

Parameters

font_rid RID

font_clear_textures(RID, Vector2i)

Removes all textures from font cache entry.

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

void font_clear_textures(RID font_rid, Vector2i size)

Parameters

font_rid RID
size Vector2i

font_draw_glyph(RID, RID, int, Vector2, int, Color)

Qualifiers: 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 TextServer.shaped_text_get_glyphs or TextServer.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(RID font_rid, RID canvas, int size, Vector2 pos, int index, Color color)

Parameters

font_rid RID
canvas RID
size int
pos Vector2
index int
color Color

font_draw_glyph_outline(RID, RID, int, int, Vector2, int, Color)

Qualifiers: 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 TextServer.shaped_text_get_glyphs or TextServer.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)

Parameters

font_rid RID
canvas RID
size int
outline_size int
pos Vector2
index int
color Color

font_get_antialiasing(RID)

Qualifiers: const

Returns font anti-aliasing mode.

int font_get_antialiasing(RID font_rid)

Parameters

font_rid RID

font_get_ascent(RID, int)

Qualifiers: const

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

float font_get_ascent(RID font_rid, int size)

Parameters

font_rid RID
size int

font_get_baseline_offset(RID)

Qualifiers: const

Returns extra baseline offset (as a fraction of font height).

float font_get_baseline_offset(RID font_rid)

Parameters

font_rid RID

font_get_char_from_glyph_index(RID, int, int)

Qualifiers: const

Returns character code associated with glyph_index, or 0 if glyph_index is invalid. See TextServer.font_get_glyph_index.

int font_get_char_from_glyph_index(RID font_rid, int size, int glyph_index)

Parameters

font_rid RID
size int
glyph_index int

font_get_descent(RID, int)

Qualifiers: const

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

float font_get_descent(RID font_rid, int size)

Parameters

font_rid RID
size int

font_get_disable_embedded_bitmaps(RID)

Qualifiers: const

Returns whether the font's embedded bitmap loading is disabled.

bool font_get_disable_embedded_bitmaps(RID font_rid)

Parameters

font_rid RID

font_get_embolden(RID)

Qualifiers: const

Returns font embolden strength.

float font_get_embolden(RID font_rid)

Parameters

font_rid RID

font_get_face_count(RID)

Qualifiers: const

Returns number of faces in the TrueType / OpenType collection.

int font_get_face_count(RID font_rid)

Parameters

font_rid RID

font_get_face_index(RID)

Qualifiers: const

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

int font_get_face_index(RID font_rid)

Parameters

font_rid RID

font_get_fixed_size(RID)

Qualifiers: const

Returns bitmap font fixed size.

int font_get_fixed_size(RID font_rid)

Parameters

font_rid RID

font_get_fixed_size_scale_mode(RID)

Qualifiers: const

Returns bitmap font scaling mode.

int font_get_fixed_size_scale_mode(RID font_rid)

Parameters

font_rid RID

font_get_generate_mipmaps(RID)

Qualifiers: const

Returns true if font texture mipmap generation is enabled.

bool font_get_generate_mipmaps(RID font_rid)

Parameters

font_rid RID

font_get_global_oversampling

Qualifiers: const

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

float font_get_global_oversampling

font_get_glyph_advance(RID, int, int)

Qualifiers: 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.

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

Parameters

font_rid RID
size int
glyph int

font_get_glyph_contours(RID, int, int)

Qualifiers: 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.

  • Two successive TextServer.CONTOUR_CURVE_TAG_ON points indicate a line segment.

  • One TextServer.CONTOUR_CURVE_TAG_OFF_CONIC point between two TextServer.CONTOUR_CURVE_TAG_ON points indicates a single conic (quadratic) Bézier arc.

  • Two TextServer.CONTOUR_CURVE_TAG_OFF_CUBIC points between two TextServer.CONTOUR_CURVE_TAG_ON points indicate a single cubic Bézier arc.

  • Two successive TextServer.CONTOUR_CURVE_TAG_OFF_CONIC points indicate two successive conic (quadratic) Bézier arcs with a virtual TextServer.CONTOUR_CURVE_TAG_ON point at their middle.

  • Each contour is closed. The last point of a contour uses the first point of a contour as its next point, and vice versa. The first point can be TextServer.CONTOUR_CURVE_TAG_OFF_CONIC point.

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

Parameters

font RID
size int
index int

font_get_glyph_index(RID, int, int, int)

Qualifiers: const

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

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

Parameters

font_rid RID
size int
char int
variation_selector int

font_get_glyph_list(RID, Vector2i)

Qualifiers: const

Returns list of rendered glyphs in the cache entry.

PackedInt32Array font_get_glyph_list(RID font_rid, Vector2i size)

Parameters

font_rid RID
size Vector2i

font_get_glyph_offset(RID, Vector2i, int)

Qualifiers: const

Returns glyph offset from the baseline.

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

Parameters

font_rid RID
size Vector2i
glyph int

font_get_glyph_size(RID, Vector2i, int)

Qualifiers: const

Returns size of the glyph.

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

Parameters

font_rid RID
size Vector2i
glyph int

font_get_glyph_texture_idx(RID, Vector2i, int)

Qualifiers: const

Returns index of the cache texture containing the glyph.

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

Parameters

font_rid RID
size Vector2i
glyph int

font_get_glyph_texture_rid(RID, Vector2i, int)

Qualifiers: 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.

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

Parameters

font_rid RID
size Vector2i
glyph int

font_get_glyph_texture_size(RID, Vector2i, int)

Qualifiers: 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.

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

Parameters

font_rid RID
size Vector2i
glyph int

font_get_glyph_uv_rect(RID, Vector2i, int)

Qualifiers: const

Returns rectangle in the cache texture containing the glyph.

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

Parameters

font_rid RID
size Vector2i
glyph int

font_get_hinting(RID)

Qualifiers: const

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

int font_get_hinting(RID font_rid)

Parameters

font_rid RID

font_get_keep_rounding_remainders(RID)

Qualifiers: const

Returns glyph position rounding behavior. If set to true, when aligning glyphs to the pixel boundaries rounding remainders are accumulated to ensure more uniform glyph distribution. This setting has no effect if subpixel positioning is enabled.

bool font_get_keep_rounding_remainders(RID font_rid)

Parameters

font_rid RID

font_get_kerning(RID, int, Vector2i)

Qualifiers: const

Returns kerning for the pair of glyphs.

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

Parameters

font_rid RID
size int
glyph_pair Vector2i

font_get_kerning_list(RID, int)

Qualifiers: const

Returns list of the kerning overrides.

Vector2i[] font_get_kerning_list(RID font_rid, int size)

Parameters

font_rid RID
size int

font_get_language_support_override(RID, String)

Returns true if support override is enabled for the language.

bool font_get_language_support_override(RID font_rid, String language)

Parameters

font_rid RID
language String

font_get_language_support_overrides(RID)

Returns list of language support overrides.

PackedStringArray font_get_language_support_overrides(RID font_rid)

Parameters

font_rid RID

font_get_msdf_pixel_range(RID)

Qualifiers: const

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

int font_get_msdf_pixel_range(RID font_rid)

Parameters

font_rid RID

font_get_msdf_size(RID)

Qualifiers: const

Returns source font size used to generate MSDF textures.

int font_get_msdf_size(RID font_rid)

Parameters

font_rid RID

font_get_name(RID)

Qualifiers: const

Returns font family name.

String font_get_name(RID font_rid)

Parameters

font_rid RID

font_get_opentype_feature_overrides(RID)

Qualifiers: const

Returns font OpenType feature set override.

Dictionary font_get_opentype_feature_overrides(RID font_rid)

Parameters

font_rid RID

font_get_ot_name_strings(RID)

Qualifiers: const

Returns Dictionary with OpenType font name strings (localized font names, version, description, license information, sample text, etc.).

Dictionary font_get_ot_name_strings(RID font_rid)

Parameters

font_rid RID

font_get_oversampling(RID)

Qualifiers: const

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

float font_get_oversampling(RID font_rid)

Parameters

font_rid RID

font_get_scale(RID, int)

Qualifiers: const

Returns scaling factor of the color bitmap font.

float font_get_scale(RID font_rid, int size)

Parameters

font_rid RID
size int

font_get_script_support_override(RID, String)

Returns true if support override is enabled for the script.

bool font_get_script_support_override(RID font_rid, String script)

Parameters

font_rid RID
script String

font_get_script_support_overrides(RID)

Returns list of script support overrides.

PackedStringArray font_get_script_support_overrides(RID font_rid)

Parameters

font_rid RID

font_get_size_cache_list(RID)

Qualifiers: const

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

Vector2i[] font_get_size_cache_list(RID font_rid)

Parameters

font_rid RID

font_get_spacing(RID, int)

Qualifiers: const

Returns the spacing for spacing (see SpacingType) in pixels (not relative to the font size).

int font_get_spacing(RID font_rid, int spacing)

Parameters

font_rid RID
spacing int

font_get_stretch(RID)

Qualifiers: const

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

int font_get_stretch(RID font_rid)

Parameters

font_rid RID

font_get_style(RID)

Qualifiers: const

Returns font style flags, see FontStyle.

int font_get_style(RID font_rid)

Parameters

font_rid RID

font_get_style_name(RID)

Qualifiers: const

Returns font style name.

String font_get_style_name(RID font_rid)

Parameters

font_rid RID

font_get_subpixel_positioning(RID)

Qualifiers: const

Returns font subpixel glyph positioning mode.

int font_get_subpixel_positioning(RID font_rid)

Parameters

font_rid RID

font_get_supported_chars(RID)

Qualifiers: const

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

String font_get_supported_chars(RID font_rid)

Parameters

font_rid RID

font_get_supported_glyphs(RID)

Qualifiers: const

Returns an array containing all glyph indices in the font.

PackedInt32Array font_get_supported_glyphs(RID font_rid)

Parameters

font_rid RID

font_get_texture_count(RID, Vector2i)

Qualifiers: const

Returns number of textures used by font cache entry.

int font_get_texture_count(RID font_rid, Vector2i size)

Parameters

font_rid RID
size Vector2i

font_get_texture_image(RID, Vector2i, int)

Qualifiers: const

Returns font cache texture image data.

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

Parameters

font_rid RID
size Vector2i
texture_index int

font_get_texture_offsets(RID, Vector2i, int)

Qualifiers: const

Returns array containing glyph packing data.

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

Parameters

font_rid RID
size Vector2i
texture_index int

font_get_transform(RID)

Qualifiers: const

Returns 2D transform applied to the font outlines.

Transform2D font_get_transform(RID font_rid)

Parameters

font_rid RID

font_get_underline_position(RID, int)

Qualifiers: const

Returns pixel offset of the underline below the baseline.

float font_get_underline_position(RID font_rid, int size)

Parameters

font_rid RID
size int

font_get_underline_thickness(RID, int)

Qualifiers: const

Returns thickness of the underline in pixels.

float font_get_underline_thickness(RID font_rid, int size)

Parameters

font_rid RID
size int

font_get_variation_coordinates(RID)

Qualifiers: const

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

Dictionary font_get_variation_coordinates(RID font_rid)

Parameters

font_rid RID

font_get_weight(RID)

Qualifiers: const

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

int font_get_weight(RID font_rid)

Parameters

font_rid RID

font_has_char(RID, int)

Qualifiers: const

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

bool font_has_char(RID font_rid, int char)

Parameters

font_rid RID
char int

font_is_allow_system_fallback(RID)

Qualifiers: const

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

bool font_is_allow_system_fallback(RID font_rid)

Parameters

font_rid RID

font_is_force_autohinter(RID)

Qualifiers: const

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

bool font_is_force_autohinter(RID font_rid)

Parameters

font_rid RID

font_is_language_supported(RID, String)

Qualifiers: const

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

bool font_is_language_supported(RID font_rid, String language)

Parameters

font_rid RID
language String

font_is_multichannel_signed_distance_field(RID)

Qualifiers: 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_multichannel_signed_distance_field(RID font_rid)

Parameters

font_rid RID

font_is_script_supported(RID, String)

Qualifiers: const

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

bool font_is_script_supported(RID font_rid, String script)

Parameters

font_rid RID
script String

font_remove_glyph(RID, Vector2i, int)

Removes specified rendered glyph information from the cache entry.

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

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

Parameters

font_rid RID
size Vector2i
glyph int

font_remove_kerning(RID, int, Vector2i)

Removes kerning override for the pair of glyphs.

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

Parameters

font_rid RID
size int
glyph_pair Vector2i

font_remove_language_support_override(RID, String)

Remove language support override.

void font_remove_language_support_override(RID font_rid, String language)

Parameters

font_rid RID
language String

font_remove_script_support_override(RID, String)

Removes script support override.

void font_remove_script_support_override(RID font_rid, String script)

Parameters

font_rid RID
script String

font_remove_size_cache(RID, Vector2i)

Removes specified font size from the cache entry.

void font_remove_size_cache(RID font_rid, Vector2i size)

Parameters

font_rid RID
size Vector2i

font_remove_texture(RID, Vector2i, int)

Removes specified texture from the cache entry.

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

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

Parameters

font_rid RID
size Vector2i
texture_index int

font_render_glyph(RID, Vector2i, int)

Renders specified glyph to the font cache texture.

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

Parameters

font_rid RID
size Vector2i
index int

font_render_range(RID, Vector2i, int, int)

Renders the range of characters to the font cache texture.

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

Parameters

font_rid RID
size Vector2i
start int
end int

font_set_allow_system_fallback(RID, bool)

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

void font_set_allow_system_fallback(RID font_rid, bool allow_system_fallback)

Parameters

font_rid RID
allow_system_fallback bool

font_set_antialiasing(RID, int)

Sets font anti-aliasing mode.

void font_set_antialiasing(RID font_rid, int antialiasing)

Parameters

font_rid RID
antialiasing int

font_set_ascent(RID, int, float)

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

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

Parameters

font_rid RID
size int
ascent float

font_set_baseline_offset(RID, float)

Sets extra baseline offset (as a fraction of font height).

void font_set_baseline_offset(RID font_rid, float baseline_offset)

Parameters

font_rid RID
baseline_offset float

font_set_data(RID, PackedByteArray)

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

void font_set_data(RID font_rid, PackedByteArray data)

Parameters

font_rid RID
data PackedByteArray

font_set_descent(RID, int, float)

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

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

Parameters

font_rid RID
size int
descent float

font_set_disable_embedded_bitmaps(RID, bool)

If set to true, embedded font bitmap loading is disabled (bitmap-only and color fonts ignore this property).

void font_set_disable_embedded_bitmaps(RID font_rid, bool disable_embedded_bitmaps)

Parameters

font_rid RID
disable_embedded_bitmaps bool

font_set_embolden(RID, float)

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

void font_set_embolden(RID font_rid, float strength)

Parameters

font_rid RID
strength float

font_set_face_index(RID, int)

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

void font_set_face_index(RID font_rid, int face_index)

Parameters

font_rid RID
face_index int

font_set_fixed_size(RID, int)

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_fixed_size(RID font_rid, int fixed_size)

Parameters

font_rid RID
fixed_size int

font_set_fixed_size_scale_mode(RID, int)

Sets bitmap font scaling mode. This property is used only if fixed_size is greater than zero.

void font_set_fixed_size_scale_mode(RID font_rid, int fixed_size_scale_mode)

Parameters

font_rid RID
fixed_size_scale_mode int

font_set_force_autohinter(RID, bool)

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

void font_set_force_autohinter(RID font_rid, bool force_autohinter)

Parameters

font_rid RID
force_autohinter bool

font_set_generate_mipmaps(RID, bool)

If set to true font texture mipmap generation is enabled.

void font_set_generate_mipmaps(RID font_rid, bool generate_mipmaps)

Parameters

font_rid RID
generate_mipmaps bool

font_set_global_oversampling(float)

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

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

void font_set_global_oversampling(float oversampling)

Parameters

oversampling float

font_set_glyph_advance(RID, int, int, Vector2)

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_advance(RID font_rid, int size, int glyph, Vector2 advance)

Parameters

font_rid RID
size int
glyph int
advance Vector2

font_set_glyph_offset(RID, Vector2i, int, Vector2)

Sets glyph offset from the baseline.

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

Parameters

font_rid RID
size Vector2i
glyph int
offset Vector2

font_set_glyph_size(RID, Vector2i, int, Vector2)

Sets size of the glyph.

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

Parameters

font_rid RID
size Vector2i
glyph int
gl_size Vector2

font_set_glyph_texture_idx(RID, Vector2i, int, int)

Sets index of the cache texture containing the glyph.

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

Parameters

font_rid RID
size Vector2i
glyph int
texture_idx int

font_set_glyph_uv_rect(RID, Vector2i, int, Rect2)

Sets rectangle in the cache texture containing the glyph.

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

Parameters

font_rid RID
size Vector2i
glyph int
uv_rect Rect2

font_set_hinting(RID, int)

Sets font hinting mode. Used by dynamic fonts only.

void font_set_hinting(RID font_rid, int hinting)

Parameters

font_rid RID
hinting int

font_set_keep_rounding_remainders(RID, bool)

Sets glyph position rounding behavior. If set to true, when aligning glyphs to the pixel boundaries rounding remainders are accumulated to ensure more uniform glyph distribution. This setting has no effect if subpixel positioning is enabled.

void font_set_keep_rounding_remainders(RID font_rid, bool keep_rounding_remainders)

Parameters

font_rid RID
keep_rounding_remainders bool

font_set_kerning(RID, int, Vector2i, Vector2)

Sets kerning for the pair of glyphs.

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

Parameters

font_rid RID
size int
glyph_pair Vector2i
kerning Vector2

font_set_language_support_override(RID, String, bool)

Adds override for TextServer.font_is_language_supported.

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

Parameters

font_rid RID
language String
supported bool

font_set_msdf_pixel_range(RID, int)

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

void font_set_msdf_pixel_range(RID font_rid, int msdf_pixel_range)

Parameters

font_rid RID
msdf_pixel_range int

font_set_msdf_size(RID, int)

Sets source font size used to generate MSDF textures.

void font_set_msdf_size(RID font_rid, int msdf_size)

Parameters

font_rid RID
msdf_size int

font_set_multichannel_signed_distance_field(RID, bool)

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_multichannel_signed_distance_field(RID font_rid, bool msdf)

Parameters

font_rid RID
msdf bool

font_set_name(RID, String)

Sets the font family name.

void font_set_name(RID font_rid, String name)

Parameters

font_rid RID
name String

font_set_opentype_feature_overrides(RID, Dictionary)

Sets font OpenType feature set override.

void font_set_opentype_feature_overrides(RID font_rid, Dictionary overrides)

Parameters

font_rid RID
overrides Dictionary

font_set_oversampling(RID, float)

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

void font_set_oversampling(RID font_rid, float oversampling)

Parameters

font_rid RID
oversampling float

font_set_scale(RID, int, float)

Sets scaling factor of the color bitmap font.

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

Parameters

font_rid RID
size int
scale float

font_set_script_support_override(RID, String, bool)

Adds override for TextServer.font_is_script_supported.

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

Parameters

font_rid RID
script String
supported bool

font_set_spacing(RID, int, int)

Sets the spacing for spacing (see SpacingType) to value in pixels (not relative to the font size).

void font_set_spacing(RID font_rid, int spacing, int value)

Parameters

font_rid RID
spacing int
value int

font_set_stretch(RID, int)

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 TextServer.font_set_face_index, TextServer.font_set_variation_coordinates, or TextServer.font_set_transform instead.

void font_set_stretch(RID font_rid, int weight)

Parameters

font_rid RID
weight int

font_set_style(RID, int)

Sets the font style flags, see FontStyle.

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

void font_set_style(RID font_rid, int style)

Parameters

font_rid RID
style int

font_set_style_name(RID, String)

Sets the font style name.

void font_set_style_name(RID font_rid, String name)

Parameters

font_rid RID
name String

font_set_subpixel_positioning(RID, int)

Sets font subpixel glyph positioning mode.

void font_set_subpixel_positioning(RID font_rid, int subpixel_positioning)

Parameters

font_rid RID
subpixel_positioning int

font_set_texture_image(RID, Vector2i, int, Image)

Sets font cache texture image data.

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

Parameters

font_rid RID
size Vector2i
texture_index int
image Image

font_set_texture_offsets(RID, Vector2i, int, PackedInt32Array)

Sets array containing glyph packing data.

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

Parameters

font_rid RID
size Vector2i
texture_index int
offset PackedInt32Array

font_set_transform(RID, Transform2D)

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_transform(RID font_rid, Transform2D transform)

Parameters

font_rid RID
transform Transform2D

font_set_underline_position(RID, int, float)

Sets pixel offset of the underline below the baseline.

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

Parameters

font_rid RID
size int
underline_position float

font_set_underline_thickness(RID, int, float)

Sets thickness of the underline in pixels.

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

Parameters

font_rid RID
size int
underline_thickness float

font_set_variation_coordinates(RID, Dictionary)

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

void font_set_variation_coordinates(RID font_rid, Dictionary variation_coordinates)

Parameters

font_rid RID
variation_coordinates Dictionary

font_set_weight(RID, int)

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 TextServer.font_set_face_index, TextServer.font_set_variation_coordinates, or TextServer.font_set_embolden instead.

void font_set_weight(RID font_rid, int weight)

Parameters

font_rid RID
weight int

font_supported_feature_list(RID)

Qualifiers: const

Returns the dictionary of the supported OpenType features.

Dictionary font_supported_feature_list(RID font_rid)

Parameters

font_rid RID

font_supported_variation_list(RID)

Qualifiers: const

Returns the dictionary of the supported OpenType variation coordinates.

Dictionary font_supported_variation_list(RID font_rid)

Parameters

font_rid RID

format_number(String, String)

Qualifiers: 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.

String format_number(String number, String language)

Parameters

number String
language String

free_rid(RID)

Frees an object created by this TextServer.

void free_rid(RID rid)

Parameters

rid RID

get_features

Qualifiers: const

Returns text server features, see Feature.

int get_features

get_hex_code_box_size(int, int)

Qualifiers: const

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

Vector2 get_hex_code_box_size(int size, int index)

Parameters

size int
index int

get_name

Qualifiers: const

Returns the name of the server interface.

String get_name

get_support_data

Qualifiers: const

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

PackedByteArray get_support_data

get_support_data_filename

Qualifiers: const

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

String get_support_data_filename

get_support_data_info

Qualifiers: const

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

String get_support_data_info

has(RID)

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

bool has(RID rid)

Parameters

rid RID

has_feature(int)

Qualifiers: const

Returns true if the server supports a feature.

bool has_feature(int feature)

Parameters

feature int

is_confusable(String, PackedStringArray)

Qualifiers: 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 TextServer.spoof_check.

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

int is_confusable(String string, PackedStringArray dict)

Parameters

string String
dict PackedStringArray

is_locale_right_to_left(String)

Qualifiers: const

Returns true if locale is right-to-left.

bool is_locale_right_to_left(String locale)

Parameters

locale String

is_valid_identifier(String)

Qualifiers: const

Returns true if string is a valid identifier.

If the text server supports the TextServer.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 TextServer.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 is_valid_identifier(String string)

Parameters

string String

is_valid_letter(int)

Qualifiers: const

Returns true if the given code point is a valid letter, i.e. it belongs to the Unicode category "L".

bool is_valid_letter(int unicode)

Parameters

unicode int

load_support_data(String)

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.

bool load_support_data(String filename)

Parameters

filename String

name_to_tag(String)

Qualifiers: const

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

int name_to_tag(String name)

Parameters

name String

parse_number(String, String)

Qualifiers: const

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

String parse_number(String number, String language)

Parameters

number String
language String

parse_structured_text(int, Array, String)

Qualifiers: const

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

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

Parameters

parser_type int
args Array
text String

percent_sign(String)

Qualifiers: const

Returns percent sign used in the language.

String percent_sign(String language)

Parameters

language String

save_support_data(String)

Qualifiers: 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.

bool save_support_data(String filename)

Parameters

filename String

shaped_get_span_count(RID)

Qualifiers: const

Returns number of text spans added using TextServer.shaped_text_add_string or TextServer.shaped_text_add_object.

int shaped_get_span_count(RID shaped)

Parameters

shaped RID

shaped_get_span_embedded_object(RID, int)

Qualifiers: const

Returns text embedded object key.

Variant shaped_get_span_embedded_object(RID shaped, int index)

Parameters

shaped RID
index int

shaped_get_span_meta(RID, int)

Qualifiers: const

Returns text span metadata.

Variant shaped_get_span_meta(RID shaped, int index)

Parameters

shaped RID
index int

shaped_set_span_update_font(RID, int, RID[], int, Dictionary)

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

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

Parameters

shaped RID
index int
fonts RID[]
size int
opentype_features Dictionary

shaped_text_add_object(RID, Variant, Vector2, int, int, float)

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_object(RID shaped, Variant key, Vector2 size, int inline_align, int length, float baseline)

Parameters

shaped RID
key Variant
size Vector2
inline_align int
length int
baseline float

shaped_text_add_string(RID, String, RID[], int, Dictionary, String, Variant)

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

bool shaped_text_add_string(RID shaped, String text, RID[] fonts, int size, Dictionary opentype_features, String language, Variant meta)

Parameters

shaped RID
text String
fonts RID[]
size int
opentype_features Dictionary
language String
meta Variant

shaped_text_clear(RID)

Clears text buffer (removes text and inline objects).

void shaped_text_clear(RID rid)

Parameters

rid RID

shaped_text_closest_character_pos(RID, int)

Qualifiers: const

Returns composite character position closest to the pos.

int shaped_text_closest_character_pos(RID shaped, int pos)

Parameters

shaped RID
pos int

shaped_text_draw(RID, RID, Vector2, float, float, Color)

Qualifiers: 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(RID shaped, RID canvas, Vector2 pos, float clip_l, float clip_r, Color color)

Parameters

shaped RID
canvas RID
pos Vector2
clip_l float
clip_r float
color Color

shaped_text_draw_outline(RID, RID, Vector2, float, float, int, Color)

Qualifiers: 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).

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

Parameters

shaped RID
canvas RID
pos Vector2
clip_l float
clip_r float
outline_size int
color Color

shaped_text_fit_to_width(RID, float, int)

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

float shaped_text_fit_to_width(RID shaped, float width, int justification_flags)

Parameters

shaped RID
width float
justification_flags int

shaped_text_get_ascent(RID)

Qualifiers: 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.

float shaped_text_get_ascent(RID shaped)

Parameters

shaped RID

shaped_text_get_carets(RID, int)

Qualifiers: const

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

Dictionary shaped_text_get_carets(RID shaped, int position)

Parameters

shaped RID
position int

shaped_text_get_character_breaks(RID)

Qualifiers: const

Returns array of the composite character boundaries.

PackedInt32Array shaped_text_get_character_breaks(RID shaped)

Parameters

shaped RID

shaped_text_get_custom_ellipsis(RID)

Qualifiers: const

Returns ellipsis character used for text clipping.

int shaped_text_get_custom_ellipsis(RID shaped)

Parameters

shaped RID

shaped_text_get_custom_punctuation(RID)

Qualifiers: const

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

String shaped_text_get_custom_punctuation(RID shaped)

Parameters

shaped RID

shaped_text_get_descent(RID)

Qualifiers: 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.

float shaped_text_get_descent(RID shaped)

Parameters

shaped RID

shaped_text_get_direction(RID)

Qualifiers: const

Returns direction of the text.

int shaped_text_get_direction(RID shaped)

Parameters

shaped RID

shaped_text_get_dominant_direction_in_range(RID, int, int)

Qualifiers: const

Returns dominant direction of in the range of text.

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

Parameters

shaped RID
start int
end int

shaped_text_get_ellipsis_glyph_count(RID)

Qualifiers: const

Returns number of glyphs in the ellipsis.

int shaped_text_get_ellipsis_glyph_count(RID shaped)

Parameters

shaped RID

shaped_text_get_ellipsis_glyphs(RID)

Qualifiers: const

Returns array of the glyphs in the ellipsis.

Dictionary[] shaped_text_get_ellipsis_glyphs(RID shaped)

Parameters

shaped RID

shaped_text_get_ellipsis_pos(RID)

Qualifiers: const

Returns position of the ellipsis.

int shaped_text_get_ellipsis_pos(RID shaped)

Parameters

shaped RID

shaped_text_get_glyph_count(RID)

Qualifiers: const

Returns number of glyphs in the buffer.

int shaped_text_get_glyph_count(RID shaped)

Parameters

shaped RID

shaped_text_get_glyphs(RID)

Qualifiers: const

Returns an array of glyphs in the visual order.

Dictionary[] shaped_text_get_glyphs(RID shaped)

Parameters

shaped RID

shaped_text_get_grapheme_bounds(RID, int)

Qualifiers: const

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

Vector2 shaped_text_get_grapheme_bounds(RID shaped, int pos)

Parameters

shaped RID
pos int

shaped_text_get_inferred_direction(RID)

Qualifiers: const

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

int shaped_text_get_inferred_direction(RID shaped)

Parameters

shaped RID

shaped_text_get_line_breaks(RID, float, int, int)

Qualifiers: const

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

PackedInt32Array shaped_text_get_line_breaks(RID shaped, float width, int start, int break_flags)

Parameters

shaped RID
width float
start int
break_flags int

shaped_text_get_line_breaks_adv(RID, PackedFloat32Array, int, bool, int)

Qualifiers: const

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

PackedInt32Array shaped_text_get_line_breaks_adv(RID shaped, PackedFloat32Array width, int start, bool once, int break_flags)

Parameters

shaped RID
width PackedFloat32Array
start int
once bool
break_flags int

shaped_text_get_object_glyph(RID, Variant)

Qualifiers: const

Returns the glyph index of the inline object.

int shaped_text_get_object_glyph(RID shaped, Variant key)

Parameters

shaped RID
key Variant

shaped_text_get_object_range(RID, Variant)

Qualifiers: const

Returns the character range of the inline object.

Vector2i shaped_text_get_object_range(RID shaped, Variant key)

Parameters

shaped RID
key Variant

shaped_text_get_object_rect(RID, Variant)

Qualifiers: const

Returns bounding rectangle of the inline object.

Rect2 shaped_text_get_object_rect(RID shaped, Variant key)

Parameters

shaped RID
key Variant

shaped_text_get_objects(RID)

Qualifiers: const

Returns array of inline objects.

Array shaped_text_get_objects(RID shaped)

Parameters

shaped RID

shaped_text_get_orientation(RID)

Qualifiers: const

Returns text orientation.

int shaped_text_get_orientation(RID shaped)

Parameters

shaped RID

shaped_text_get_parent(RID)

Qualifiers: const

Returns the parent buffer from which the substring originates.

RID shaped_text_get_parent(RID shaped)

Parameters

shaped RID

shaped_text_get_preserve_control(RID)

Qualifiers: const

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

bool shaped_text_get_preserve_control(RID shaped)

Parameters

shaped RID

shaped_text_get_preserve_invalid(RID)

Qualifiers: 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.

bool shaped_text_get_preserve_invalid(RID shaped)

Parameters

shaped RID

shaped_text_get_range(RID)

Qualifiers: const

Returns substring buffer character range in the parent buffer.

Vector2i shaped_text_get_range(RID shaped)

Parameters

shaped RID

shaped_text_get_selection(RID, int, int)

Qualifiers: const

Returns selection rectangles for the specified character range.

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

Parameters

shaped RID
start int
end int

shaped_text_get_size(RID)

Qualifiers: const

Returns size of the text.

Vector2 shaped_text_get_size(RID shaped)

Parameters

shaped RID

shaped_text_get_spacing(RID, int)

Qualifiers: const

Returns extra spacing added between glyphs or lines in pixels.

int shaped_text_get_spacing(RID shaped, int spacing)

Parameters

shaped RID
spacing int

shaped_text_get_trim_pos(RID)

Qualifiers: const

Returns the position of the overrun trim.

int shaped_text_get_trim_pos(RID shaped)

Parameters

shaped RID

shaped_text_get_underline_position(RID)

Qualifiers: const

Returns pixel offset of the underline below the baseline.

float shaped_text_get_underline_position(RID shaped)

Parameters

shaped RID

shaped_text_get_underline_thickness(RID)

Qualifiers: const

Returns thickness of the underline.

float shaped_text_get_underline_thickness(RID shaped)

Parameters

shaped RID

shaped_text_get_width(RID)

Qualifiers: const

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

float shaped_text_get_width(RID shaped)

Parameters

shaped RID

shaped_text_get_word_breaks(RID, int, int)

Qualifiers: const

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

PackedInt32Array shaped_text_get_word_breaks(RID shaped, int grapheme_flags, int skip_grapheme_flags)

Parameters

shaped RID
grapheme_flags int
skip_grapheme_flags int

shaped_text_has_visible_chars(RID)

Qualifiers: const

Returns true if text buffer contains any visible characters.

bool shaped_text_has_visible_chars(RID shaped)

Parameters

shaped RID

shaped_text_hit_test_grapheme(RID, float)

Qualifiers: const

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

int shaped_text_hit_test_grapheme(RID shaped, float coords)

Parameters

shaped RID
coords float

shaped_text_hit_test_position(RID, float)

Qualifiers: const

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

int shaped_text_hit_test_position(RID shaped, float coords)

Parameters

shaped RID
coords float

shaped_text_is_ready(RID)

Qualifiers: const

Returns true if buffer is successfully shaped.

bool shaped_text_is_ready(RID shaped)

Parameters

shaped RID

shaped_text_next_character_pos(RID, int)

Qualifiers: const

Returns composite character end position closest to the pos.

int shaped_text_next_character_pos(RID shaped, int pos)

Parameters

shaped RID
pos int

shaped_text_next_grapheme_pos(RID, int)

Qualifiers: const

Returns grapheme end position closest to the pos.

int shaped_text_next_grapheme_pos(RID shaped, int pos)

Parameters

shaped RID
pos int

shaped_text_overrun_trim_to_width(RID, float, int)

Trims text if it exceeds the given width.

void shaped_text_overrun_trim_to_width(RID shaped, float width, int overrun_trim_flags)

Parameters

shaped RID
width float
overrun_trim_flags int

shaped_text_prev_character_pos(RID, int)

Qualifiers: const

Returns composite character start position closest to the pos.

int shaped_text_prev_character_pos(RID shaped, int pos)

Parameters

shaped RID
pos int

shaped_text_prev_grapheme_pos(RID, int)

Qualifiers: const

Returns grapheme start position closest to the pos.

int shaped_text_prev_grapheme_pos(RID shaped, int pos)

Parameters

shaped RID
pos int

shaped_text_resize_object(RID, Variant, Vector2, int, float)

Sets new size and alignment of embedded object.

bool shaped_text_resize_object(RID shaped, Variant key, Vector2 size, int inline_align, float baseline)

Parameters

shaped RID
key Variant
size Vector2
inline_align int
baseline float

shaped_text_set_bidi_override(RID, Array)

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_bidi_override(RID shaped, Array override)

Parameters

shaped RID
override Array

shaped_text_set_custom_ellipsis(RID, int)

Sets ellipsis character used for text clipping.

void shaped_text_set_custom_ellipsis(RID shaped, int char)

Parameters

shaped RID
char int

shaped_text_set_custom_punctuation(RID, String)

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

void shaped_text_set_custom_punctuation(RID shaped, String punct)

Parameters

shaped RID
punct String

shaped_text_set_direction(RID, int)

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

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

void shaped_text_set_direction(RID shaped, int direction)

Parameters

shaped RID
direction int

shaped_text_set_orientation(RID, int)

Sets desired text orientation.

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

void shaped_text_set_orientation(RID shaped, int orientation)

Parameters

shaped RID
orientation int

shaped_text_set_preserve_control(RID, bool)

If set to true text buffer will display control characters.

void shaped_text_set_preserve_control(RID shaped, bool enabled)

Parameters

shaped RID
enabled bool

shaped_text_set_preserve_invalid(RID, bool)

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

void shaped_text_set_preserve_invalid(RID shaped, bool enabled)

Parameters

shaped RID
enabled bool

shaped_text_set_spacing(RID, int, int)

Sets extra spacing added between glyphs or lines in pixels.

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

Parameters

shaped RID
spacing int
value int

shaped_text_shape(RID)

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.

bool shaped_text_shape(RID shaped)

Parameters

shaped RID

shaped_text_sort_logical(RID)

Returns text glyphs in the logical order.

Dictionary[] shaped_text_sort_logical(RID shaped)

Parameters

shaped RID

shaped_text_substr(RID, int, int)

Qualifiers: const

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

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

Parameters

shaped RID
start int
length int

shaped_text_tab_align(RID, PackedFloat32Array)

Aligns shaped text to the given tab-stops.

float shaped_text_tab_align(RID shaped, PackedFloat32Array tab_stops)

Parameters

shaped RID
tab_stops PackedFloat32Array

spoof_check(String)

Qualifiers: 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 TextServer.FEATURE_UNICODE_SECURITY feature.

bool spoof_check(String string)

Parameters

string String

string_get_character_breaks(String, String)

Qualifiers: const

Returns array of the composite character boundaries.

var ts = TextServerManager.get_primary_interface()
print(ts.string_get_character_breaks("Test ❤️‍🔥 Test")) # Prints [1, 2, 3, 4, 5, 9, 10, 11, 12, 13, 14]

PackedInt32Array string_get_character_breaks(String string, String language)

Parameters

string String
language String

string_get_word_breaks(String, String, int)

Qualifiers: 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()
# Corresponds to the substrings "The", "Godot", "Engine", and "4".
print(ts.string_get_word_breaks("The Godot Engine, 4")) # Prints [0, 3, 4, 9, 10, 16, 18, 19]
# Corresponds to the substrings "The", "Godot", "Engin", and "e, 4".
print(ts.string_get_word_breaks("The Godot Engine, 4", "en", 5)) # Prints [0, 3, 4, 9, 10, 15, 15, 19]
# Corresponds to the substrings "The Godot" and "Engine, 4".
print(ts.string_get_word_breaks("The Godot Engine, 4", "en", 10)) # Prints [0, 9, 10, 19]

PackedInt32Array string_get_word_breaks(String string, String language, int chars_per_line)

Parameters

string String
language String
chars_per_line int

string_to_lower(String, String)

Qualifiers: const

Returns the string converted to lowercase.

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

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

String string_to_lower(String string, String language)

Parameters

string String
language String

string_to_title(String, String)

Qualifiers: const

Returns the string converted to title case.

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

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

String string_to_title(String string, String language)

Parameters

string String
language String

string_to_upper(String, String)

Qualifiers: const

Returns the string converted to uppercase.

Note: Casing is locale dependent and context sensitive if server support TextServer.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)

Parameters

string String
language String

strip_diacritics(String)

Qualifiers: const

Strips diacritics from the string.

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

String strip_diacritics(String string)

Parameters

string String

tag_to_name(int)

Qualifiers: const

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

String tag_to_name(int tag)

Parameters

tag int