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 resourec, use [method free_rid] method.
Creates new buffer for complex text layout, with the given [code]direction[/code] and [code]orientation[/code]. 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 [code]font_rid[/code] at the size [code]size[/code].
[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].
Draws single glyph outline of size [code]outline_size[/code] into a canvas item at the position, using [code]font_rid[/code] at the size [code]size[/code].
[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].
Returns the font ascent (number of pixels above the baseline).
Returns the font descent (number of pixels below the baseline).
Returns bitmap font fixed size.
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 [code]char[/code], optionally modified by the [code]variation_selector[/code].
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 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 [code]language[/code].
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 [code]script[/code].
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 extra spacing added between glyphs in pixels.
Returns font style flags, see [enum FontStyle].
Returns font style name.
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 the first free pixel in the each column of texture. Should be the same size as texture width or empty.
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 [code]true[/code] if a Unicode [code]char[/code] is available in the font.
Returns [code]true[/code] if font 8-bit anitialiased glyph rendering is supported and enabled.
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 font 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 the the font cache texture.
Renders the range of characters to the font cache texture.
If set to [code]true[/code], 8-bit antialiased glyph rendering is used, otherwise 1-bit rendering is used. Used by dynamic fonts only.
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 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.
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 extra spacing added between glyphs in pixels.
Sets the font style flags, see [enum FontStyle].
Set the font style name.
Sets font cache texture image data.
Sets array containing the first free pixel in the each column of texture. Should be the same size as texture width or empty.
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.
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 [code]language[/code].
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 [code]rid[/code] is valid resource owned by this text server.
Returns [code]true[/code] if the server supports a feature.
Returns [code]true[/code] if locale is right-to-left.
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 a number from the numeral systems used in [code]language[/code] to Western Arabic (0..9).
Returns percent sign used in the [code]language[/code].
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.
Adds inline object to the text buffer, [code]key[/code] must be unique. In the text, object is represented as [code]length[/code] 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 [code]color[/code]. [code]pos[/code] 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 [code]color[/code]. [code]pos[/code] specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout).
Adjusts text with 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 [code]position[/code] 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 text 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.
Sets text orientation.
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 position of the 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.
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 [code]pos[/code].
Trims text if it exceeds the given width.
Returns composite character start position closest to the [code]pos[/code].
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 [code]TEXT_DIRECTION_AUTO[/code], 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.
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 [code]shaped[/code] text buffer (including inline objects).
Aligns shaped text to the given tab-stops.
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.
Converts OpenType tag to readable feature, variation, script or language name.
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 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 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.
Break the line between the words, or any unconnected graphemes if line is too short to fit the whole word.
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.
Disables font hinting (smoother but less crisp).
Use the light font hinting mode.
Use the default font hinting mode (crisper but less smooth).
TextServer supports bidirectional 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 system fonts.
TextServer supports variable fonts.
TextServer supports locale dependent and context sensitive case conversion.
TextServer require external data file for some 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.