Interface for the fonts and complex text layouts.
[TextServer] is the API backend for managing fonts, and rendering complex text.
Creates new, empty font cache entry resource. To free the resulting resource, use [method free_rid] method.
Creates new buffer for complex text layout, with the given [param direction] and [param orientation]. To free the resulting buffer, use [method free_rid] method.
[b]Note:[/b] Direction is ignored if server does not support [constant FEATURE_BIDI_LAYOUT] feature (supported by [TextServerAdvanced]).
[b]Note:[/b] Orientation is ignored if server does not support [constant FEATURE_VERTICAL_LAYOUT] feature (supported by [TextServerAdvanced]).
Draws box displaying character hexadecimal code. Used for replacing missing characters.
Removes all rendered glyphs information from the cache entry.
[b]Note:[/b] This function will not remove textures associated with the glyphs, use [method font_remove_texture] to remove them manually.
Removes all kerning overrides.
Removes all font sizes from the cache entry.
Removes all textures from font cache entry.
[b]Note:[/b] This function will not remove glyphs associated with the texture, use [method font_remove_glyph] to remove them manually.
Draws single glyph into a canvas item at the position, using [param font_rid] at the size [param size].
[b]Note:[/b] Glyph index is specific to the font, use glyphs indices returned by [method shaped_text_get_glyphs] or [method font_get_glyph_index].
[b]Note:[/b] If there are pending glyphs to render, calling this function might trigger the texture cache update.
Draws single glyph outline of size [param outline_size] into a canvas item at the position, using [param font_rid] at the size [param size].
[b]Note:[/b] Glyph index is specific to the font, use glyphs indices returned by [method shaped_text_get_glyphs] or [method font_get_glyph_index].
[b]Note:[/b] If there are pending glyphs to render, calling this function might trigger the texture cache update.
Returns font anti-aliasing mode.
Returns the font ascent (number of pixels above the baseline).
Returns character code associated with [param glyph_index], or [code]0[/code] if [param glyph_index] is invalid. See [method font_get_glyph_index].
Returns the font descent (number of pixels below the baseline).
Returns font embolden strength.
Returns number of faces in the TrueType / OpenType collection.
Recturns an active face index in the TrueType / OpenType collection.
Returns bitmap font fixed size.
Returns [code]true[/code] if font texture mipmap generation is enabled.
Returns the font oversampling factor, shared by all fonts in the TextServer.
Returns glyph advance (offset of the next glyph).
[b]Note:[/b] Advance for glyphs outlines is the same as the base glyph advance and is not saved.
Returns outline contours of the glyph as a [code]Dictionary[/code] with the following contents:
[code]points[/code] - [PackedVector3Array], containing outline points. [code]x[/code] and [code]y[/code] are point coordinates. [code]z[/code] is the type of the point, using the [enum ContourPointTag] values.
[code]contours[/code] - [PackedInt32Array], containing indices the end points of each contour.
[code]orientation[/code] - [bool], contour orientation. If [code]true[/code], clockwise contours must be filled.
Returns the glyph index of a [param char], optionally modified by the [param variation_selector]. See [method font_get_char_from_glyph_index].
Returns list of rendered glyphs in the cache entry.
Returns glyph offset from the baseline.
Returns size of the glyph.
Returns index of the cache texture containing the glyph.
Returns resource ID of the cache texture containing the glyph.
[b]Note:[/b] If there are pending glyphs to render, calling this function might trigger the texture cache update.
Returns size of the cache texture containing the glyph.
[b]Note:[/b] If there are pending glyphs to render, calling this function might trigger the texture cache update.
Returns rectangle in the cache texture containing the glyph.
Returns the font hinting mode. Used by dynamic fonts only.
Returns kerning for the pair of glyphs.
Returns list of the kerning overrides.
Returns [code]true[/code] if support override is enabled for the [param language].
Returns list of language support overrides.
Returns the width of the range around the shape between the minimum and maximum representable signed distance.
Returns source font size used to generate MSDF textures.
Returns font family name.
Returns font OpenType feature set override.
Returns font oversampling factor, if set to [code]0.0[/code] global oversampling factor is used instead. Used by dynamic fonts only.
Returns scaling factor of the color bitmap font.
Returns [code]true[/code] if support override is enabled for the [param script].
Returns list of script support overrides.
Returns list of the font sizes in the cache. Each size is [code]Vector2i[/code] with font size and outline size.
Returns font stretch amount, compared to a normal width. A percentage value between [code]50%[/code] and [code]200%[/code].
Returns font style flags, see [enum FontStyle].
Returns font style name.
Returns font subpixel glyph positioning mode.
Returns a string containing all the characters available in the font.
Returns number of textures used by font cache entry.
Returns font cache texture image data.
Returns array containing glyph packing data.
Returns 2D transform applied to the font outlines.
Returns pixel offset of the underline below the baseline.
Returns thickness of the underline in pixels.
Returns variation coordinates for the specified font cache entry. See [method font_supported_variation_list] for more info.
Returns weight (boldness) of the font. A value in the [code]100...999[/code] range, normal font weight is [code]400[/code], bold font weight is [code]700[/code].
Returns [code]true[/code] if a Unicode [param char] is available in the font.
Returns [code]true[/code] if system fonts can be automatically used as fallbacks.
Returns [code]true[/code] if auto-hinting is supported and preferred over font built-in hinting. Used by dynamic fonts only.
Returns [code]true[/code], if font supports given language ([url=https://en.wikipedia.org/wiki/ISO_639-1]ISO 639[/url] code).
Returns [code]true[/code] if glyphs of all sizes are rendered using single multichannel signed distance field generated from the dynamic font vector data.
Returns [code]true[/code], if font supports given script (ISO 15924 code).
Removes specified rendered glyph information from the cache entry.
[b]Note:[/b] This function will not remove textures associated with the glyphs, use [method font_remove_texture] to remove them manually.
Removes kerning override for the pair of glyphs.
Remove language support override.
Removes script support override.
Removes specified font size from the cache entry.
Removes specified texture from the cache entry.
[b]Note:[/b] This function will not remove glyphs associated with the texture, remove them manually, using [method font_remove_glyph].
Renders specified glyph to the font cache texture.
Renders the range of characters to the font cache texture.
If set to [code]true[/code], system fonts can be automatically used as fallbacks.
Sets font anti-aliasing mode.
Sets the font ascent (number of pixels above the baseline).
Sets font source data, e.g contents of the dynamic font source file.
Sets the font descent (number of pixels below the baseline).
Sets font embolden strength. If [param strength] is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
Sets an active face index in the TrueType / OpenType collection.
Sets bitmap font fixed size. If set to value greater than zero, same cache entry will be used for all font sizes.
If set to [code]true[/code] auto-hinting is preferred over font built-in hinting.
If set to [code]true[/code] font texture mipmap generation is enabled.
Sets oversampling factor, shared by all font in the TextServer.
[b]Note:[/b] This value can be automatically changed by display server.
Sets glyph advance (offset of the next glyph).
[b]Note:[/b] Advance for glyphs outlines is the same as the base glyph advance and is not saved.
Sets glyph offset from the baseline.
Sets size of the glyph.
Sets index of the cache texture containing the glyph.
Sets rectangle in the cache texture containing the glyph.
Sets font hinting mode. Used by dynamic fonts only.
Sets kerning for the pair of glyphs.
Adds override for [method font_is_language_supported].
Sets the width of the range around the shape between the minimum and maximum representable signed distance.
Sets source font size used to generate MSDF textures.
If set to [code]true[/code], 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.
[b]Note:[/b] 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.
Sets the font family name.
Sets font OpenType feature set override.
Sets font oversampling factor, if set to [code]0.0[/code] global oversampling factor is used instead. Used by dynamic fonts only.
Sets scaling factor of the color bitmap font.
Adds override for [method font_is_script_supported].
Sets font stretch amount, compared to a normal width. A percentage value between [code]50%[/code] and [code]200%[/code].
[b]Note:[/b] This value is used for font matching only and will not affect font rendering. Use [method font_set_face_index], [method font_set_variation_coordinates], or [method font_set_transform] instead.
Sets the font style flags, see [enum FontStyle].
[b]Note:[/b] This value is used for font matching only and will not affect font rendering. Use [method font_set_face_index], [method font_set_variation_coordinates], [method font_set_embolden], or [method font_set_transform] instead.
Sets the font style name.
Sets font subpixel glyph positioning mode.
Sets font cache texture image data.
Sets array containing glyph packing data.
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 [code]Transform2D(1.0, slant, 0.0, 1.0, 0.0, 0.0)[/code].
Sets pixel offset of the underline below the baseline.
Sets thickness of the underline in pixels.
Sets variation coordinates for the specified font cache entry. See [method font_supported_variation_list] for more info.
Sets weight (boldness) of the font. A value in the [code]100...999[/code] range, normal font weight is [code]400[/code], bold font weight is [code]700[/code].
[b]Note:[/b] This value is used for font matching only and will not affect font rendering. Use [method font_set_face_index], [method font_set_variation_coordinates], or [method font_set_embolden] instead.
Returns the dictionary of the supported OpenType features.
Returns the dictionary of the supported OpenType variation coordinates.
Converts a number from the Western Arabic (0..9) to the numeral systems used in [param language].
If [param language] is omitted, the active locale will be used.
Frees an object created by this [TextServer].
Returns text server features, see [enum Feature].
Returns size of the replacement character (box with character hexadecimal code that is drawn in place of invalid characters).
Returns the name of the server interface.
Returns default TextServer database (e.g. ICU break iterators and dictionaries) filename.
Returns TextServer database (e.g. ICU break iterators and dictionaries) description.
Returns [code]true[/code] if [param rid] is valid resource owned by this text server.
Returns [code]true[/code] if the server supports a feature.
Returns index of the first string in [param dict] which is visually confusable with the [param string], or [code]-1[/code] if none is found.
[b]Note:[/b] This method doesn't detect invisible characters, for spoof detection use it in combination with [method spoof_check].
[b]Note:[/b] Always returns [code]-1[/code] if the server does not support the [constant FEATURE_UNICODE_SECURITY] feature.
Returns [code]true[/code] if locale is right-to-left.
Returns [code]true[/code] if [param string] is a valid identifier.
If the text server supports the [constant FEATURE_UNICODE_IDENTIFIERS] feature, a valid identifier must:
- Conform to normalization form C.
- Begin with a Unicode character of class XID_Start or [code]"_"[/code].
- May contain Unicode characters of class XID_Continue in the other positions.
- Use UAX #31 recommended scripts only (mixed scripts are allowed).
If the [constant FEATURE_UNICODE_IDENTIFIERS] feature is not supported, a valid identifier must:
- Begin with a Unicode character of class XID_Start or [code]"_"[/code].
- May contain Unicode characters of class XID_Continue in the other positions.
Loads optional TextServer database (e.g. ICU break iterators and dictionaries).
[b]Note:[/b] This function should be called before any other TextServer functions used, otherwise it won't have any effect.
Converts readable feature, variation, script or language name to OpenType tag.
Converts [param number] from the numeral systems used in [param language] to Western Arabic (0..9).
Default implementation of the BiDi algorithm override function. See [enum StructuredTextParser] for more info.
Returns percent sign used in the [param language].
Saves optional TextServer database (e.g. ICU break iterators and dictionaries) to the file.
[b]Note:[/b] This function is used by during project export, to include TextServer database.
Returns number of text spans added using [method shaped_text_add_string] or [method shaped_text_add_object].
Returns text span metadata.
Changes text span font, font size and OpenType features, without changing the text.
Adds inline object to the text buffer, [param key] must be unique. In the text, object is represented as [param length] object replacement characters.
Adds text span and font to draw it to the text buffer.
Clears text buffer (removes text and inline objects).
Draw shaped text into a canvas item at a given position, with [param color]. [param pos] specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout).
Draw the outline of the shaped text into a canvas item at a given position, with [param color]. [param pos] specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout).
Adjusts text width to fit to specified width, returns new text width.
Returns the text ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical).
[b]Note:[/b] Overall ascent can be higher than font ascent, if some glyphs are displaced from the baseline.
Returns shapes of the carets corresponding to the character offset [param position] in the text. Returned caret shape is 1 pixel wide rectangle.
Returns custom punctuation character list, used for word breaking. If set to empty string, server defaults are used.
Returns the text descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical).
[b]Note:[/b] Overall descent can be higher than font descent, if some glyphs are displaced from the baseline.
Returns direction of the text.
Returns dominant direction of in the range of text.
Returns number of glyphs in the ellipsis.
Returns array of the glyphs in the ellipsis.
Returns position of the ellipsis.
Returns number of glyphs in the buffer.
Returns an array of glyphs in the visual order.
Returns composite character's bounds as offsets from the start of the line.
Returns direction of the text, inferred by the BiDi algorithm.
Breaks text to the lines and returns character ranges for each line.
Breaks text to the lines and columns. Returns character ranges for each segment.
Returns bounding rectangle of the inline object.
Returns array of inline objects.
Returns text orientation.
Returns the parent buffer from which the substring originates.
Returns [code]true[/code] if text buffer is configured to display control characters.
Returns [code]true[/code] if text buffer is configured to display hexadecimal codes in place of invalid characters.
[b]Note:[/b] If set to [code]false[/code], nothing is displayed in place of invalid characters.
Returns substring buffer character range in the parent buffer.
Returns selection rectangles for the specified character range.
Returns size of the text.
Returns extra spacing added between glyphs or lines in pixels.
Returns the position of the overrun trim.
Returns pixel offset of the underline below the baseline.
Returns thickness of the underline.
Returns width (for horizontal layout) or height (for vertical) of the text.
Breaks text into words and returns array of character ranges. Use [param grapheme_flags] to set what characters are used for breaking (see [enum GraphemeFlag]).
Returns [code]true[/code], if text buffer contents any visible characters.
Returns grapheme index at the specified pixel offset at the baseline, or [code]-1[/code] if none is found.
Returns caret character offset at the specified pixel offset at the baseline. This function always returns a valid position.
Returns [code]true[/code] if buffer is successfully shaped.
Returns composite character end position closest to the [param pos].
Trims text if it exceeds the given width.
Returns composite character start position closest to the [param pos].
Sets new size and alignment of embedded object.
Overrides BiDi for the structured text.
Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately.
Sets custom punctuation character list, used for word breaking. If set to empty string, server defaults are used.
Sets desired text direction. If set to [constant DIRECTION_AUTO], direction will be detected based on the buffer contents and current locale.
[b]Note:[/b] Direction is ignored if server does not support [constant FEATURE_BIDI_LAYOUT] feature (supported by [TextServerAdvanced]).
Sets desired text orientation.
[b]Note:[/b] Orientation is ignored if server does not support [constant FEATURE_VERTICAL_LAYOUT] feature (supported by [TextServerAdvanced]).
If set to [code]true[/code] text buffer will display control characters.
If set to [code]true[/code] text buffer will display invalid characters as hexadecimal codes, otherwise nothing is displayed.
Sets extra spacing added between glyphs or lines in pixels.
Shapes buffer if it's not shaped. Returns [code]true[/code] if the string is shaped successfully.
[b]Note:[/b] It is not necessary to call this function manually, buffer will be shaped automatically as soon as any of its output data is requested.
Returns text glyphs in the logical order.
Returns text buffer for the substring of the text in the [param shaped] text buffer (including inline objects).
Aligns shaped text to the given tab-stops.
Returns [code]true[/code] if [param string] is likely to be an attempt at confusing the reader.
[b]Note:[/b] Always returns [code]false[/code] if the server does not support the [constant FEATURE_UNICODE_SECURITY] feature.
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 [param chars_per_line] is greater than zero, line break boundaries are returned instead.
[codeblock]
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]
[/codeblock]
Returns the string converted to lowercase.
[b]Note:[/b] Casing is locale dependent and context sensitive if server support [constant FEATURE_CONTEXT_SENSITIVE_CASE_CONVERSION] feature (supported by [TextServerAdvanced]).
[b]Note:[/b] The result may be longer or shorter than the original.
Returns the string converted to uppercase.
[b]Note:[/b] Casing is locale dependent and context sensitive if server support [constant FEATURE_CONTEXT_SENSITIVE_CASE_CONVERSION] feature (supported by [TextServerAdvanced]).
[b]Note:[/b] The result may be longer or shorter than the original.
Strips diacritics from the string.
[b]Note:[/b] The result may be longer or shorter than the original.
Converts OpenType tag to readable feature, variation, script or language name.
Font glyphs are rasterized as 1-bit bitmaps.
Font glyphs are rasterized as 8-bit grayscale anti-aliased bitmaps.
Font glyphs are rasterized for LCD screens.
LCD subpixel layout is determined by the value of [code]gui/theme/lcd_subpixel_layout[/code] project settings.
LCD subpixel anti-aliasing mode is suitable only for rendering horizontal, unscaled text in 2D.
Unknown or unsupported subpixel layout, LCD subpixel antialiasing is disabled.
Horizontal RGB subpixel layout.
Horizontal BGR subpixel layout.
Vertical RGB subpixel layout.
Vertical BGR subpixel layout.
Text direction is determined based on contents and current locale.
Text is written from left to right.
Text is written from right to left.
Text writing direction is the same as base string writing direction. Used for BiDi override only.
Text is written horizontally.
Left to right text is written vertically from top to bottom.
Right to left text is written vertically from bottom to top.
Do not justify text.
Justify text by adding and removing kashidas.
Justify text by changing width of the spaces between the words.
Remove trailing and leading spaces from the justified text.
Only apply justification to the part of the text after the last tab.
Apply justification to the trimmed line with ellipsis.
Do not apply justification to the last line of the paragraph.
Do not apply justification to the last line of the paragraph with visible characters (takes precedence over [constant JUSTIFICATION_SKIP_LAST_LINE]).
Always apply justification to the paragraphs with a single line ([constant JUSTIFICATION_SKIP_LAST_LINE] and [constant JUSTIFICATION_SKIP_LAST_LINE_WITH_VISIBLE_CHARS] are ignored).
Autowrap is disabled.
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.
Wraps the text inside the node's bounding rectangle by soft-breaking between words.
Behaves similarly to [constant AUTOWRAP_WORD], but force-breaks a word if that single word does not fit in one line.
Do not break the line.
Break the line at the line mandatory break characters (e.g. [code]"\n"[/code]).
Break the line between the words.
Break the line between any unconnected graphemes.
Should be used only in conjunction with [constant BREAK_WORD_BOUND], break the line between any unconnected graphemes, if it's impossible to break it between the words.
Remove edge spaces from the broken line segments.
Trims text before the shaping. e.g, increasing [member Label.visible_characters] or [member RichTextLabel.visible_characters] value is visually identical to typing the text.
Displays glyphs that are mapped to the first [member Label.visible_characters] or [member RichTextLabel.visible_characters] characters from the beginning of the text.
Displays [member Label.visible_ratio] or [member RichTextLabel.visible_ratio] glyphs, starting from the left or from the right, depending on [member Control.layout_direction] value.
Displays [member Label.visible_ratio] or [member RichTextLabel.visible_ratio] glyphs, starting from the left.
Displays [member Label.visible_ratio] or [member RichTextLabel.visible_ratio] glyphs, starting from the right.
No text trimming is performed.
Trims the text per character.
Trims the text per word.
Trims the text per character and adds an ellipsis to indicate that parts are hidden.
Trims the text per word and adds an ellipsis to indicate that parts are hidden.
No trimming is performed.
Trims the text when it exceeds the given width.
Trims the text per word instead of per grapheme.
Determines whether an ellipsis should be added at the end of the text.
Determines whether the ellipsis at the end of the text is enforced and may not be hidden.
Grapheme is supported by the font, and can be drawn.
Grapheme is part of right-to-left or bottom-to-top run.
Grapheme is not part of source text, it was added by justification process.
Grapheme is whitespace.
Grapheme is mandatory break point (e.g. [code]"\n"[/code]).
Grapheme is optional break point (e.g. space).
Grapheme is the tabulation character.
Grapheme is kashida.
Grapheme is punctuation character.
Grapheme is underscore character.
Grapheme is connected to the previous grapheme. Breaking line before this grapheme is not safe.
It is safe to insert a U+0640 before this grapheme for elongation.
Grapheme is an object replacement character for the embedded object.
Disables font hinting (smoother but less crisp).
Use the light font hinting mode.
Use the default font hinting mode (crisper but less smooth).
[b]Note:[/b] This hinting mode changes both horizontal and vertical glyph metrics. If applied to monospace font, some glyphs might have different width.
Glyph horizontal position is rounded to the whole pixel size, each glyph is rasterized once.
Glyph horizontal position is rounded based on font size.
- To one quarter of the pixel size if font size is smaller or equal to [constant SUBPIXEL_POSITIONING_ONE_QUARTER_MAX_SIZE].
- To one half of the pixel size if font size is smaller or equal to [constant SUBPIXEL_POSITIONING_ONE_HALF_MAX_SIZE].
- To the whole pixel size for larger fonts.
Glyph horizontal position is rounded to one half of the pixel size, each glyph is rasterized up to two times.
Glyph horizontal position is rounded to one quarter of the pixel size, each glyph is rasterized up to four times.
Maximum font size which will use one half of the pixel subpixel positioning in [constant SUBPIXEL_POSITIONING_AUTO] mode.
Maximum font size which will use one quarter of the pixel subpixel positioning in [constant SUBPIXEL_POSITIONING_AUTO] mode.
TextServer supports simple text layouts.
TextServer supports bidirectional text layouts.
TextServer supports vertical layouts.
TextServer supports complex text shaping.
TextServer supports justification using kashidas.
TextServer supports complex line/word breaking rules (e.g. dictionary based).
TextServer supports loading bitmap fonts.
TextServer supports loading dynamic (TrueType, OpeType, etc.) fonts.
TextServer supports multichannel signed distance field dynamic font rendering.
TextServer supports loading system fonts.
TextServer supports variable fonts.
TextServer supports locale dependent and context sensitive case conversion.
TextServer require external data file for some features, see [method load_support_data].
TextServer supports UAX #31 identifier validation, see [method is_valid_identifier].
TextServer supports [url=https://unicode.org/reports/tr36/]Unicode Technical Report #36[/url] and [url=https://unicode.org/reports/tr39/]Unicode Technical Standard #39[/url] based spoof detection features.
Contour point is on the curve.
Contour point isn't on the curve, but serves as a control point for a conic (quadratic) Bézier arc.
Contour point isn't on the curve, but serves as a control point for a cubic Bézier arc.
Spacing for each glyph.
Spacing for the space character.
Spacing at the top of the line.
Spacing at the bottom of the line.
Font is bold.
Font is italic or oblique.
Font have fixed-width characters.
Use default Unicode BiDi algorithm.
BiDi override for URI.
BiDi override for file path.
BiDi override for email.
BiDi override for lists.
Structured text options: list separator [code]String[/code].
BiDi override for GDScript.
User defined structured text BiDi override function.