Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

TextServer

繼承: RefCounted < Object

被繼承: TextServerExtension

字形管理和文字算繪的伺服器介面。

說明

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()

方法

RID

create_font()

RID

create_font_linked_variation(font_rid: RID)

RID

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

void

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

void

font_clear_glyphs(font_rid: RID, size: Vector2i)

void

font_clear_kerning_map(font_rid: RID, size: int)

void

font_clear_size_cache(font_rid: RID)

void

font_clear_system_fallback_cache()

void

font_clear_textures(font_rid: RID, size: Vector2i)

void

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

void

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

FontAntialiasing

font_get_antialiasing(font_rid: RID) const

float

font_get_ascent(font_rid: RID, size: int) const

float

font_get_baseline_offset(font_rid: RID) const

int

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

float

font_get_descent(font_rid: RID, size: int) const

bool

font_get_disable_embedded_bitmaps(font_rid: RID) const

float

font_get_embolden(font_rid: RID) const

int

font_get_face_count(font_rid: RID) const

int

font_get_face_index(font_rid: RID) const

int

font_get_fixed_size(font_rid: RID) const

FixedSizeScaleMode

font_get_fixed_size_scale_mode(font_rid: RID) const

bool

font_get_generate_mipmaps(font_rid: RID) const

float

font_get_global_oversampling() const

Vector2

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

Dictionary

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

int

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

PackedInt32Array

font_get_glyph_list(font_rid: RID, size: Vector2i) const

Vector2

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

Vector2

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

int

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

RID

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

Vector2

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

Rect2

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

Hinting

font_get_hinting(font_rid: RID) const

bool

font_get_keep_rounding_remainders(font_rid: RID) const

Vector2

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

Array[Vector2i]

font_get_kerning_list(font_rid: RID, size: int) const

bool

font_get_language_support_override(font_rid: RID, language: String)

PackedStringArray

font_get_language_support_overrides(font_rid: RID)

int

font_get_msdf_pixel_range(font_rid: RID) const

int

font_get_msdf_size(font_rid: RID) const

String

font_get_name(font_rid: RID) const

Dictionary

font_get_opentype_feature_overrides(font_rid: RID) const

Dictionary

font_get_ot_name_strings(font_rid: RID) const

float

font_get_oversampling(font_rid: RID) const

PackedColorArray

font_get_palette_colors(font_rid: RID, index: int) const

int

font_get_palette_count(font_rid: RID) const

PackedColorArray

font_get_palette_custom_colors(font_rid: RID) const

String

font_get_palette_name(font_rid: RID, index: int) const

float

font_get_scale(font_rid: RID, size: int) const

bool

font_get_script_support_override(font_rid: RID, script: String)

PackedStringArray

font_get_script_support_overrides(font_rid: RID)

Array[Dictionary]

font_get_size_cache_info(font_rid: RID) const

Array[Vector2i]

font_get_size_cache_list(font_rid: RID) const

int

font_get_spacing(font_rid: RID, spacing: SpacingType) const

int

font_get_stretch(font_rid: RID) const

BitField[FontStyle]

font_get_style(font_rid: RID) const

String

font_get_style_name(font_rid: RID) const

SubpixelPositioning

font_get_subpixel_positioning(font_rid: RID) const

String

font_get_supported_chars(font_rid: RID) const

PackedInt32Array

font_get_supported_glyphs(font_rid: RID) const

int

font_get_texture_count(font_rid: RID, size: Vector2i) const

Image

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

PackedInt32Array

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

Transform2D

font_get_transform(font_rid: RID) const

float

font_get_underline_position(font_rid: RID, size: int) const

float

font_get_underline_thickness(font_rid: RID, size: int) const

int

font_get_used_palette(font_rid: RID) const

Dictionary

font_get_variation_coordinates(font_rid: RID) const

int

font_get_weight(font_rid: RID) const

bool

font_has_char(font_rid: RID, char: int) const

bool

font_is_allow_system_fallback(font_rid: RID) const

bool

font_is_force_autohinter(font_rid: RID) const

bool

font_is_language_supported(font_rid: RID, language: String) const

bool

font_is_modulate_color_glyphs(font_rid: RID) const

bool

font_is_multichannel_signed_distance_field(font_rid: RID) const

bool

font_is_script_supported(font_rid: RID, script: String) const

void

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

void

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

void

font_remove_language_support_override(font_rid: RID, language: String)

void

font_remove_script_support_override(font_rid: RID, script: String)

void

font_remove_size_cache(font_rid: RID, size: Vector2i)

void

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

void

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

void

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

void

font_set_allow_system_fallback(font_rid: RID, allow_system_fallback: bool)

void

font_set_antialiasing(font_rid: RID, antialiasing: FontAntialiasing)

void

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

void

font_set_baseline_offset(font_rid: RID, baseline_offset: float)

void

font_set_data(font_rid: RID, data: PackedByteArray)

void

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

void

font_set_disable_embedded_bitmaps(font_rid: RID, disable_embedded_bitmaps: bool)

void

font_set_embolden(font_rid: RID, strength: float)

void

font_set_face_index(font_rid: RID, face_index: int)

void

font_set_fixed_size(font_rid: RID, fixed_size: int)

void

font_set_fixed_size_scale_mode(font_rid: RID, fixed_size_scale_mode: FixedSizeScaleMode)

void

font_set_force_autohinter(font_rid: RID, force_autohinter: bool)

void

font_set_generate_mipmaps(font_rid: RID, generate_mipmaps: bool)

void

font_set_global_oversampling(oversampling: float)

void

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

void

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

void

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

void

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

void

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

void

font_set_hinting(font_rid: RID, hinting: Hinting)

void

font_set_keep_rounding_remainders(font_rid: RID, keep_rounding_remainders: bool)

void

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

void

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

void

font_set_modulate_color_glyphs(font_rid: RID, modulate: bool)

void

font_set_msdf_pixel_range(font_rid: RID, msdf_pixel_range: int)

void

font_set_msdf_size(font_rid: RID, msdf_size: int)

void

font_set_multichannel_signed_distance_field(font_rid: RID, msdf: bool)

void

font_set_name(font_rid: RID, name: String)

void

font_set_opentype_feature_overrides(font_rid: RID, overrides: Dictionary)

void

font_set_oversampling(font_rid: RID, oversampling: float)

void

font_set_palette_custom_colors(font_rid: RID, colors: PackedColorArray)

void

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

void

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

void

font_set_spacing(font_rid: RID, spacing: SpacingType, value: int)

void

font_set_stretch(font_rid: RID, weight: int)

void

font_set_style(font_rid: RID, style: BitField[FontStyle])

void

font_set_style_name(font_rid: RID, name: String)

void

font_set_subpixel_positioning(font_rid: RID, subpixel_positioning: SubpixelPositioning)

void

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

void

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

void

font_set_transform(font_rid: RID, transform: Transform2D)

void

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

void

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

void

font_set_used_palette(font_rid: RID, index: int)

void

font_set_variation_coordinates(font_rid: RID, variation_coordinates: Dictionary)

void

font_set_weight(font_rid: RID, weight: int)

Dictionary

font_supported_feature_list(font_rid: RID) const

Dictionary

font_supported_variation_list(font_rid: RID) const

String

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

void

free_rid(rid: RID)

int

get_features() const

Vector2

get_hex_code_box_size(size: int, index: int) const

String

get_name() const

PackedByteArray

get_support_data() const

String

get_support_data_filename() const

String

get_support_data_info() const

bool

has(rid: RID)

bool

has_feature(feature: Feature) const

int

is_confusable(string: String, dict: PackedStringArray) const

bool

is_locale_right_to_left(locale: String) const

bool

is_locale_using_support_data(locale: String) const

bool

is_valid_identifier(string: String) const

bool

is_valid_letter(unicode: int) const

bool

load_support_data(filename: String)

int

name_to_tag(name: String) const

String

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

Array[Vector3i]

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

String

percent_sign(language: String = "") const

bool

save_support_data(filename: String) const

int

shaped_get_run_count(shaped: RID) const

Direction

shaped_get_run_direction(shaped: RID, index: int) const

RID

shaped_get_run_font_rid(shaped: RID, index: int) const

int

shaped_get_run_font_size(shaped: RID, index: int) const

Vector2i

shaped_get_run_glyph_range(shaped: RID, index: int) const

String

shaped_get_run_language(shaped: RID, index: int) const

Variant

shaped_get_run_object(shaped: RID, index: int) const

Vector2i

shaped_get_run_range(shaped: RID, index: int) const

String

shaped_get_run_text(shaped: RID, index: int) const

int

shaped_get_span_count(shaped: RID) const

Variant

shaped_get_span_embedded_object(shaped: RID, index: int) const

Variant

shaped_get_span_meta(shaped: RID, index: int) const

Variant

shaped_get_span_object(shaped: RID, index: int) const

String

shaped_get_span_text(shaped: RID, index: int) const

String

shaped_get_text(shaped: RID) const

void

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

bool

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

bool

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

void

shaped_text_clear(rid: RID)

int

shaped_text_closest_character_pos(shaped: RID, pos: int) const

void

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

void

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

RID

shaped_text_duplicate(rid: RID)

float

shaped_text_fit_to_width(shaped: RID, width: float, justification_flags: BitField[JustificationFlag] = 3)

float

shaped_text_get_ascent(shaped: RID) const

Dictionary

shaped_text_get_carets(shaped: RID, position: int) const

PackedInt32Array

shaped_text_get_character_breaks(shaped: RID) const

int

shaped_text_get_custom_ellipsis(shaped: RID) const

String

shaped_text_get_custom_punctuation(shaped: RID) const

float

shaped_text_get_descent(shaped: RID) const

Direction

shaped_text_get_direction(shaped: RID) const

Direction

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

int

shaped_text_get_ellipsis_glyph_count(shaped: RID) const

Array[Dictionary]

shaped_text_get_ellipsis_glyphs(shaped: RID) const

int

shaped_text_get_ellipsis_pos(shaped: RID) const

int

shaped_text_get_glyph_count(shaped: RID) const

Array[Dictionary]

shaped_text_get_glyphs(shaped: RID) const

Vector2

shaped_text_get_grapheme_bounds(shaped: RID, pos: int) const

Direction

shaped_text_get_inferred_direction(shaped: RID) const

PackedInt32Array

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

PackedInt32Array

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

int

shaped_text_get_object_glyph(shaped: RID, key: Variant) const

Vector2i

shaped_text_get_object_range(shaped: RID, key: Variant) const

Rect2

shaped_text_get_object_rect(shaped: RID, key: Variant) const

Array

shaped_text_get_objects(shaped: RID) const

Orientation

shaped_text_get_orientation(shaped: RID) const

RID

shaped_text_get_parent(shaped: RID) const

bool

shaped_text_get_preserve_control(shaped: RID) const

bool

shaped_text_get_preserve_invalid(shaped: RID) const

Vector2i

shaped_text_get_range(shaped: RID) const

PackedVector2Array

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

Vector2

shaped_text_get_size(shaped: RID) const

int

shaped_text_get_spacing(shaped: RID, spacing: SpacingType) const

int

shaped_text_get_trim_pos(shaped: RID) const

float

shaped_text_get_underline_position(shaped: RID) const

float

shaped_text_get_underline_thickness(shaped: RID) const

float

shaped_text_get_width(shaped: RID) const

PackedInt32Array

shaped_text_get_word_breaks(shaped: RID, grapheme_flags: BitField[GraphemeFlag] = 264, skip_grapheme_flags: BitField[GraphemeFlag] = 4) const

bool

shaped_text_has_object(shaped: RID, key: Variant) const

bool

shaped_text_has_visible_chars(shaped: RID) const

int

shaped_text_hit_test_grapheme(shaped: RID, coords: float) const

int

shaped_text_hit_test_position(shaped: RID, coords: float) const

bool

shaped_text_is_ready(shaped: RID) const

int

shaped_text_next_character_pos(shaped: RID, pos: int) const

int

shaped_text_next_grapheme_pos(shaped: RID, pos: int) const

void

shaped_text_overrun_trim_to_width(shaped: RID, width: float = 0, overrun_trim_flags: BitField[TextOverrunFlag] = 0)

int

shaped_text_prev_character_pos(shaped: RID, pos: int) const

int

shaped_text_prev_grapheme_pos(shaped: RID, pos: int) const

bool

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

void

shaped_text_set_bidi_override(shaped: RID, override: Array)

void

shaped_text_set_custom_ellipsis(shaped: RID, char: int)

void

shaped_text_set_custom_punctuation(shaped: RID, punct: String)

void

shaped_text_set_direction(shaped: RID, direction: Direction = 0)

void

shaped_text_set_orientation(shaped: RID, orientation: Orientation = 0)

void

shaped_text_set_preserve_control(shaped: RID, enabled: bool)

void

shaped_text_set_preserve_invalid(shaped: RID, enabled: bool)

void

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

bool

shaped_text_shape(shaped: RID)

Array[Dictionary]

shaped_text_sort_logical(shaped: RID)

RID

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

float

shaped_text_tab_align(shaped: RID, tab_stops: PackedFloat32Array)

bool

spoof_check(string: String) const

PackedInt32Array

string_get_character_breaks(string: String, language: String = "") const

PackedInt32Array

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

String

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

String

string_to_title(string: String, language: String = "") const

String

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

String

strip_diacritics(string: String) const

String

tag_to_name(tag: int) const


列舉

enum FontAntialiasing: 🔗

FontAntialiasing FONT_ANTIALIASING_NONE = 0

字形字形柵格化為 1 位的點陣圖。

FontAntialiasing FONT_ANTIALIASING_GRAY = 1

字形字形柵格化為 8 位的灰度抗鋸齒點陣圖。

FontAntialiasing FONT_ANTIALIASING_LCD = 2

Font glyphs are rasterized for LCD screens.

LCD subpixel layout is determined by the value of the ProjectSettings.gui/theme/lcd_subpixel_layout setting.

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


enum FontLCDSubpixelLayout: 🔗

FontLCDSubpixelLayout FONT_LCD_SUBPIXEL_LAYOUT_NONE = 0

未知或不支援的次圖元佈局,禁用 LCD 次圖元抗鋸齒。

FontLCDSubpixelLayout FONT_LCD_SUBPIXEL_LAYOUT_HRGB = 1

水平 RGB 次圖元佈局。

FontLCDSubpixelLayout FONT_LCD_SUBPIXEL_LAYOUT_HBGR = 2

水平 BGR 次圖元佈局。

FontLCDSubpixelLayout FONT_LCD_SUBPIXEL_LAYOUT_VRGB = 3

垂直 RGB 次圖元佈局。

FontLCDSubpixelLayout FONT_LCD_SUBPIXEL_LAYOUT_VBGR = 4

垂直 BGR 次圖元佈局。

FontLCDSubpixelLayout FONT_LCD_SUBPIXEL_LAYOUT_MAX = 5

Represents the size of the FontLCDSubpixelLayout enum.


enum Direction: 🔗

Direction DIRECTION_AUTO = 0

文字的書寫方向由根據內容和目前區域設定確定。

Direction DIRECTION_LTR = 1

文字從左至右書寫。

Direction DIRECTION_RTL = 2

文字從右至左書寫。

Direction DIRECTION_INHERITED = 3

文字的書寫方向與基礎字串書寫方向一致。僅用於 BiDi 覆蓋。


enum Orientation: 🔗

Orientation ORIENTATION_HORIZONTAL = 0

文字水平書寫。

Orientation ORIENTATION_VERTICAL = 1

從左至右的文字從上到下書寫。

從右至左的文字從下到上書寫。


flags JustificationFlag: 🔗

JustificationFlag JUSTIFICATION_NONE = 0

不兩端對齊文字。

JustificationFlag JUSTIFICATION_KASHIDA = 1

通過新增和移除 Kashida 來兩端對齊文字。

JustificationFlag JUSTIFICATION_WORD_BOUND = 2

通過更改單詞之間空格的寬度來兩端對齊文字。

JustificationFlag JUSTIFICATION_TRIM_EDGE_SPACES = 4

從兩端對齊的文字中移除前綴和後綴的空格。

JustificationFlag JUSTIFICATION_AFTER_LAST_TAB = 8

僅對最後一個定位字元之後的文字套用兩端對齊。

JustificationFlag JUSTIFICATION_CONSTRAIN_ELLIPSIS = 16

使用省略號對修剪行套用對齊。

JustificationFlag JUSTIFICATION_SKIP_LAST_LINE = 32

段落中的最後一行不套用兩端對齊。

JustificationFlag JUSTIFICATION_SKIP_LAST_LINE_WITH_VISIBLE_CHARS = 64

段落中存在可見字元的最後一行不套用兩端對齊(優先於 JUSTIFICATION_SKIP_LAST_LINE)。

JustificationFlag JUSTIFICATION_DO_NOT_SKIP_SINGLE_LINE = 128

始終對只有一行的段落套用兩端對齊(忽略 JUSTIFICATION_SKIP_LAST_LINEJUSTIFICATION_SKIP_LAST_LINE_WITH_VISIBLE_CHARS)。


enum AutowrapMode: 🔗

AutowrapMode AUTOWRAP_OFF = 0

自動換行已禁用。

AutowrapMode AUTOWRAP_ARBITRARY = 1

讓文字在節點的邊界矩形內自動換行,允許在任意位置斷行,在空間非常有限的情況下非常有用。

AutowrapMode AUTOWRAP_WORD = 2

讓文字在節點的邊界矩形內自動換行,允許在單詞之間進行軟換行。

AutowrapMode AUTOWRAP_WORD_SMART = 3

行為與 AUTOWRAP_WORD 類似,但如果一行的大小無法放下該單詞,則會強制斷開該單詞。


flags LineBreakFlag: 🔗

LineBreakFlag BREAK_NONE = 0

不換行。

LineBreakFlag BREAK_MANDATORY = 1

在強制分行符號處換行(例如 "\n")。

LineBreakFlag BREAK_WORD_BOUND = 2

在單詞之間換行。

LineBreakFlag BREAK_GRAPHEME_BOUND = 4

在任何不相連的字素之間換行。

LineBreakFlag BREAK_ADAPTIVE = 8

只應與 BREAK_WORD_BOUND 一起使用,如果不可能在單詞之間換行,則在任何不相連的字素之間換行。

LineBreakFlag BREAK_TRIM_EDGE_SPACES = 16

已棄用: Use BREAK_TRIM_START_EDGE_SPACES | BREAK_TRIM_END_EDGE_SPACES instead.

移除每一行頭尾的空格。

LineBreakFlag BREAK_TRIM_INDENT = 32

Subtract first line indentation width from all lines after the first one.

LineBreakFlag BREAK_TRIM_START_EDGE_SPACES = 64

Remove spaces and line break characters from the start of broken line segments.

E.g, after line breaking, the second segment of the following text test  \n  next, is next if the flag is set, and `` next`` if it is not.

LineBreakFlag BREAK_TRIM_END_EDGE_SPACES = 128

Remove spaces and line break characters from the end of broken line segments.

E.g, after line breaking, the first segment of the following text test  \n  next, is test if the flag is set, and test  \n if it is not.


enum VisibleCharactersBehavior: 🔗

VisibleCharactersBehavior VC_CHARS_BEFORE_SHAPING = 0

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

Note: In this mode, trimmed text is not processed at all. It is not accounted for in line breaking and size calculations.

VisibleCharactersBehavior VC_CHARS_AFTER_SHAPING = 1

顯示對應到文字開頭的前 Label.visible_charactersRichTextLabel.visible_characters 個字元的字形。

VisibleCharactersBehavior VC_GLYPHS_AUTO = 2

顯示字形數量由 Label.visible_ratioRichTextLabel.visible_ratio 決定,從左至右計數還是從右至左計數由 Control.layout_direction 的值決定。

VisibleCharactersBehavior VC_GLYPHS_LTR = 3

顯示字形數量由 Label.visible_ratioRichTextLabel.visible_ratio 決定,從左側開始計數。

VisibleCharactersBehavior VC_GLYPHS_RTL = 4

顯示字形數量由 Label.visible_ratioRichTextLabel.visible_ratio 決定,從右側開始計數。


enum OverrunBehavior: 🔗

OverrunBehavior OVERRUN_NO_TRIMMING = 0

不執行文字修剪。

OverrunBehavior OVERRUN_TRIM_CHAR = 1

逐字元修剪文字。

OverrunBehavior OVERRUN_TRIM_WORD = 2

逐單詞修剪文字。

OverrunBehavior OVERRUN_TRIM_ELLIPSIS = 3

Trims the text per character and adds an ellipsis to indicate that parts are hidden if trimmed text is 6 characters or longer.

OverrunBehavior OVERRUN_TRIM_WORD_ELLIPSIS = 4

Trims the text per word and adds an ellipsis to indicate that parts are hidden if trimmed text is 6 characters or longer.

OverrunBehavior OVERRUN_TRIM_ELLIPSIS_FORCE = 5

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

OverrunBehavior OVERRUN_TRIM_WORD_ELLIPSIS_FORCE = 6

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


flags TextOverrunFlag: 🔗

TextOverrunFlag OVERRUN_NO_TRIM = 0

不執行修剪。

TextOverrunFlag OVERRUN_TRIM = 1

當文字超過給定寬度時,修剪文字。

TextOverrunFlag OVERRUN_TRIM_WORD_ONLY = 2

逐詞修剪文字,而不是逐字素修剪文字。

TextOverrunFlag OVERRUN_ADD_ELLIPSIS = 4

決定是否應在文字末尾新增省略號。

TextOverrunFlag OVERRUN_ENFORCE_ELLIPSIS = 8

決定是否應在文字末尾強制新增省略號,該省略號無法被隱藏。

TextOverrunFlag OVERRUN_JUSTIFICATION_AWARE = 16

Accounts for the text being justified before attempting to trim it (see JustificationFlag).

TextOverrunFlag OVERRUN_SHORT_STRING_ELLIPSIS = 32

Determines whether the ellipsis should be added regardless of the string length, otherwise it is added only if the string is 6 characters or longer.


flags GraphemeFlag: 🔗

GraphemeFlag GRAPHEME_IS_VALID = 1

字素由字形支援,並且可以被繪製。

GraphemeFlag GRAPHEME_IS_RTL = 2

字素是從右至左或從下至上書寫的一部分。

GraphemeFlag GRAPHEME_IS_VIRTUAL = 4

字素不是源文字的一部分,而是通過兩端對齊過程新增的。

GraphemeFlag GRAPHEME_IS_SPACE = 8

字素是空白字元。

GraphemeFlag GRAPHEME_IS_BREAK_HARD = 16

字素是強制換行點(例如 "\n")。

GraphemeFlag GRAPHEME_IS_BREAK_SOFT = 32

字素是可選換行點(例如空格)。

GraphemeFlag GRAPHEME_IS_TAB = 64

字素是定位字元。

GraphemeFlag GRAPHEME_IS_ELONGATION = 128

字素是 Kashida。

GraphemeFlag GRAPHEME_IS_PUNCTUATION = 256

字素是標點符號。

GraphemeFlag GRAPHEME_IS_UNDERSCORE = 512

字素是底線。

GraphemeFlag GRAPHEME_IS_CONNECTED = 1024

字素與前一個字素相連。在這個字素之前換行是不安全的。

GraphemeFlag GRAPHEME_IS_SAFE_TO_INSERT_TATWEEL = 2048

在這個字素之前插入 U+0640 以進行伸長是安全的。

GraphemeFlag GRAPHEME_IS_EMBEDDED_OBJECT = 4096

字素是内嵌物件的物件替換字元。

GraphemeFlag GRAPHEME_IS_SOFT_HYPHEN = 8192

Grapheme is a soft hyphen.


enum Hinting: 🔗

Hinting HINTING_NONE = 0

禁用字形提示(更平滑但不那麼清晰)。

Hinting HINTING_LIGHT = 1

使用淺色字形提示模式。

Hinting HINTING_NORMAL = 2

使用預設的字形微調模式(更銳利,但平滑度更低)。

注意:此處的微調模式會改變字形的水平和垂直度量。套用於等寬字形時,可能會讓部分字形的寬度發生變化。


enum SubpixelPositioning: 🔗

SubpixelPositioning SUBPIXEL_POSITIONING_DISABLED = 0

將字形的水平位置四捨五入至整數圖元大小,每個字形光柵化一次。

SubpixelPositioning SUBPIXEL_POSITIONING_AUTO = 1

將字形的水平位置根據字形大小進行四捨五入。

SubpixelPositioning SUBPIXEL_POSITIONING_ONE_HALF = 2

將字形的水平位置四捨五入至圖元大小的一半,每個字形最多光柵化兩次。

SubpixelPositioning SUBPIXEL_POSITIONING_ONE_QUARTER = 3

將字形的水平位置四捨五入至圖元大小的四分之一,每個字形最多光柵化四次。

SubpixelPositioning SUBPIXEL_POSITIONING_ONE_HALF_MAX_SIZE = 20

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

SubpixelPositioning SUBPIXEL_POSITIONING_ONE_QUARTER_MAX_SIZE = 16

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


enum Feature: 🔗

Feature FEATURE_SIMPLE_LAYOUT = 1

TextServer 支援簡單排版。

Feature FEATURE_BIDI_LAYOUT = 2

TextServer 支援雙向排版。

Feature FEATURE_VERTICAL_LAYOUT = 4

TextServer 支援垂直佈局。

Feature FEATURE_SHAPING = 8

TextServer 支援複雜文字塑形。

Feature FEATURE_KASHIDA_JUSTIFICATION = 16

TextServer 支援使用 kashida 進行兩端對齊。

Feature FEATURE_BREAK_ITERATORS = 32

TextServer 支援複雜斷行/斷詞規則(例如基於字典)。

Feature FEATURE_FONT_BITMAP = 64

TextServer 支援載入點陣字型。

Feature FEATURE_FONT_DYNAMIC = 128

TextServer 支援載入動態字形(TrueType、OpeType 等)。

Feature FEATURE_FONT_MSDF = 256

TextServer 支援多通道有符號距離場動態字形的算繪。

Feature FEATURE_FONT_SYSTEM = 512

TextServer 支援載入系統字形。

Feature FEATURE_FONT_VARIABLE = 1024

TextServer 支援可變字形。

Feature FEATURE_CONTEXT_SENSITIVE_CASE_CONVERSION = 2048

TextServer 支援依賴於區域設定、本文敏感的大小寫轉換。

Feature FEATURE_USE_SUPPORT_DATA = 4096

TextServer 的某些功能需要外部資料檔案,見 load_support_data()

Feature FEATURE_UNICODE_IDENTIFIERS = 8192

TextServer 支援 UAX #31 識別字驗證,見 is_valid_identifier()

Feature FEATURE_UNICODE_SECURITY = 16384

TextServer 支援基於 Unicode 技術報告 #36Unicode 技術標準 #39 的欺騙偵測功能。


enum ContourPointTag: 🔗

ContourPointTag CONTOUR_CURVE_TAG_ON = 1

輪廓點在曲線上。

ContourPointTag CONTOUR_CURVE_TAG_OFF_CONIC = 0

輪廓點不在曲線上,而是作為圓錐(二次)貝茲曲線的控制點。

ContourPointTag CONTOUR_CURVE_TAG_OFF_CUBIC = 2

輪廓點不在曲線上,而是作為三次貝茲曲線的控制點。


enum SpacingType: 🔗

SpacingType SPACING_GLYPH = 0

每個字形的間距。

SpacingType SPACING_SPACE = 1

空格字元的間距。

SpacingType SPACING_TOP = 2

行頂部的間距。

SpacingType SPACING_BOTTOM = 3

行底部的間距。

SpacingType SPACING_MAX = 4

Represents the size of the SpacingType enum.


flags FontStyle: 🔗

FontStyle FONT_BOLD = 1

字形為粗體。

FontStyle FONT_ITALIC = 2

字形為斜體(italic)或偽斜體(oblique)。

FontStyle FONT_FIXED_WIDTH = 4

Font has fixed-width characters (also known as monospace).


enum StructuredTextParser: 🔗

StructuredTextParser STRUCTURED_TEXT_DEFAULT = 0

使用預設的 Unicode BiDi 演算法。

StructuredTextParser STRUCTURED_TEXT_URI = 1

URI 的 BiDi 覆蓋。

StructuredTextParser STRUCTURED_TEXT_FILE = 2

檔路徑的 BiDi 覆蓋。

StructuredTextParser STRUCTURED_TEXT_EMAIL = 3

電子郵件的 BiDi 覆蓋。

StructuredTextParser STRUCTURED_TEXT_LIST = 4

BiDi override for lists. Structured text options: list separator String.

StructuredTextParser STRUCTURED_TEXT_GDSCRIPT = 5

GDScript 的 BiDi 覆蓋。

StructuredTextParser STRUCTURED_TEXT_CUSTOM = 6

使用者定義的結構化文字 BiDi 覆蓋函式。


enum FixedSizeScaleMode: 🔗

FixedSizeScaleMode FIXED_SIZE_SCALE_DISABLE = 0

Bitmap font is not scaled.

FixedSizeScaleMode FIXED_SIZE_SCALE_INTEGER_ONLY = 1

Bitmap font is scaled to the closest integer multiple of the font's fixed size. This is the recommended option for pixel art fonts.

FixedSizeScaleMode FIXED_SIZE_SCALE_ENABLED = 2

Bitmap font is scaled to an arbitrary (fractional) size. This is the recommended option for non-pixel art fonts.


方法說明

RID create_font() 🔗

新建空的字形快取條目資源。要釋放生成的資源,請使用 free_rid() 方法。


RID create_font_linked_variation(font_rid: RID) 🔗

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


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

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

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

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


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

繪製顯示字元十六進位碼的框。用於替換缺失的字元。


void font_clear_glyphs(font_rid: RID, size: Vector2i) 🔗

Removes all rendered glyph information from the cache entry.

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


void font_clear_kerning_map(font_rid: RID, size: int) 🔗

移除所有字距調整覆蓋。


void font_clear_size_cache(font_rid: RID) 🔗

從快取條目中移除所有的字形大小。


void font_clear_system_fallback_cache() 🔗

Frees all automatically loaded system fonts.


void font_clear_textures(font_rid: RID, size: Vector2i) 🔗

從字形快取條目中移除所有的紋理。

注意:該函式不會移除與紋理關聯的字形,請使用 font_remove_glyph() 手動移除。


void font_draw_glyph(font_rid: RID, canvas: RID, size: int, pos: Vector2, index: int, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const 🔗

Draws single glyph into a canvas item at the position, using font_rid at the size size. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.

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

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


void font_draw_glyph_outline(font_rid: RID, canvas: RID, size: int, outline_size: int, pos: Vector2, index: int, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const 🔗

Draws single glyph outline of size outline_size into a canvas item at the position, using font_rid at the size size. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.

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

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


FontAntialiasing font_get_antialiasing(font_rid: RID) const 🔗

返回字形的抗鋸齒模式。


float font_get_ascent(font_rid: RID, size: int) const 🔗

返回字形的上升幅度(超出基線的圖元數)。


float font_get_baseline_offset(font_rid: RID) const 🔗

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


int font_get_char_from_glyph_index(font_rid: RID, size: int, glyph_index: int) const 🔗

返回與 glyph_index 關聯的字元碼,如果 glyph_index 無效則返回 0。見 font_get_glyph_index()


float font_get_descent(font_rid: RID, size: int) const 🔗

返回字形的減少量(低於基線的圖元數)。


bool font_get_disable_embedded_bitmaps(font_rid: RID) const 🔗

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


float font_get_embolden(font_rid: RID) const 🔗

返回字形的加粗力度。


int font_get_face_count(font_rid: RID) const 🔗

返回 TrueType / OpenType 集合中的字形數。


int font_get_face_index(font_rid: RID) const 🔗

返回 TrueType / OpenType 集合中的活動字形索引。


int font_get_fixed_size(font_rid: RID) const 🔗

返回點陣字型的固定大小。


FixedSizeScaleMode font_get_fixed_size_scale_mode(font_rid: RID) const 🔗

Returns bitmap font scaling mode.


bool font_get_generate_mipmaps(font_rid: RID) const 🔗

如果啟用了字形紋理 mipmap 生成,則返回 true


float font_get_global_oversampling() const 🔗

已棄用: Use Viewport oversampling, or the oversampling argument of the draw_* methods instead.

This method does nothing and always returns 1.0.


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

返回字形前進量(下一個字形的偏移量)。

注意:字形輪廓的前進量,與基礎字形的前進量相同,不會被保存。


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

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

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

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

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


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

返回 char 的字形索引,可以用 variation_selector 修改。見 font_get_char_from_glyph_index()


PackedInt32Array font_get_glyph_list(font_rid: RID, size: Vector2i) const 🔗

返回快取條目中的已算繪字形列表。


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

返回字形的基線偏移量。


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

返回該字形的大小。


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

返回包含該字形的快取紋理的索引。


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

返回包含字形的快取紋理的資源 ID。

注意:如果有待算繪的字形,呼叫此函式可能會觸發紋理快取的更新。


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

返回包含字形的快取紋理的大小。

注意:如果有待算繪的字形,呼叫此函式可能會觸發紋理快取的更新。


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

返回包含該字形的快取紋理中的矩形。


Hinting font_get_hinting(font_rid: RID) const 🔗

返回字形微調模式。僅用於動態字形。


bool font_get_keep_rounding_remainders(font_rid: RID) 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.


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

返回字形對的字距調整。


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

返回字距調整覆蓋的列表。


bool font_get_language_support_override(font_rid: RID, language: String) 🔗

如果為 language 啟用了支援覆蓋,則返回 true


PackedStringArray font_get_language_support_overrides(font_rid: RID) 🔗

返回語言支援覆蓋的列表。


int font_get_msdf_pixel_range(font_rid: RID) const 🔗

返回最小和最大可表示有符號距離之間形狀周圍範圍的寬度。


int font_get_msdf_size(font_rid: RID) const 🔗

返回用於生成 MSDF 紋理的源字形大小。


String font_get_name(font_rid: RID) const 🔗

返回字形家族名稱。


Dictionary font_get_opentype_feature_overrides(font_rid: RID) const 🔗

返回字形 OpenType 功能集覆蓋。


Dictionary font_get_ot_name_strings(font_rid: RID) const 🔗

返回 OpenType 字形名稱字串的 Dictionary(當地語系化的字形名稱、版本、描述、許可資訊、範例文字等)。


float font_get_oversampling(font_rid: RID) const 🔗

Returns oversampling factor override. If set to a positive value, overrides the oversampling factor of the viewport this font is used in. See Viewport.oversampling. This value doesn't override the oversampling parameter of draw_* methods. Used by dynamic fonts only.


PackedColorArray font_get_palette_colors(font_rid: RID, index: int) const 🔗

Returns the array in the predefined color palette at index. Palette contains all colors used to render font glyphs. Each palette has the same number of colors. Colors can be overridden using font_set_palette_custom_colors().


int font_get_palette_count(font_rid: RID) const 🔗

Returns the number of predefined color palettes. Palette contains all colors used to render font glyphs. Each palette has the same number of colors.


PackedColorArray font_get_palette_custom_colors(font_rid: RID) const 🔗

Returns array of custom colors to override predefined palette.


String font_get_palette_name(font_rid: RID, index: int) const 🔗

Returns the name of the predefined color palette at index. Palette contains all colors used to render font glyphs. Each palette has the same number of colors.


float font_get_scale(font_rid: RID, size: int) const 🔗

返回顏色點陣字型的縮放係數。


bool font_get_script_support_override(font_rid: RID, script: String) 🔗

如果為 script 啟用了支援覆蓋,則返回 true


PackedStringArray font_get_script_support_overrides(font_rid: RID) 🔗

返回文字支援覆蓋的列表。


Array[Dictionary] font_get_size_cache_info(font_rid: RID) const 🔗

Returns font cache information, each entry contains the following fields: Vector2i size_px - font size in pixels, float viewport_oversampling - viewport oversampling factor, int glyphs - number of rendered glyphs, int textures - number of used textures, int textures_size - size of texture data in bytes.


Array[Vector2i] font_get_size_cache_list(font_rid: RID) const 🔗

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


int font_get_spacing(font_rid: RID, spacing: SpacingType) const 🔗

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


int font_get_stretch(font_rid: RID) const 🔗

返回與正常寬度相比的字形拉伸量。一個介於 50%200% 之間的百分比值。


BitField[FontStyle] font_get_style(font_rid: RID) const 🔗

Returns font style flags.


String font_get_style_name(font_rid: RID) const 🔗

返回字形樣式名稱。


SubpixelPositioning font_get_subpixel_positioning(font_rid: RID) const 🔗

返回字形的次圖元字形定位模式。


String font_get_supported_chars(font_rid: RID) const 🔗

返回包含字形中所有可用字元的字串。


PackedInt32Array font_get_supported_glyphs(font_rid: RID) const 🔗

Returns an array containing all glyph indices in the font.


int font_get_texture_count(font_rid: RID, size: Vector2i) const 🔗

返回字形快取條目所使用的紋理數。


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

返回字形快取紋理圖像資料。


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

返回包含字形打包資料的陣列。


Transform2D font_get_transform(font_rid: RID) const 🔗

返回套用於字形輪廓的 2D 變換。


float font_get_underline_position(font_rid: RID, size: int) const 🔗

返回基線下方底線的圖元偏移。


float font_get_underline_thickness(font_rid: RID, size: int) const 🔗

返回底線的粗細度,單位為圖元。


int font_get_used_palette(font_rid: RID) const 🔗

Returns used palette index.


Dictionary font_get_variation_coordinates(font_rid: RID) const 🔗

返回指定字形快取條目的變體座標。詳見 font_supported_variation_list()


int font_get_weight(font_rid: RID) const 🔗

返回該字形的字重(粗度)。一個在 100...999 範圍內的值,正常字形字重為 400,粗體字形字重為 700


bool font_has_char(font_rid: RID, char: int) const 🔗

如果該字形中包含 Unicode 字元 char,則返回 true


bool font_is_allow_system_fallback(font_rid: RID) const 🔗

如果可以自動使用系統字形作為退回字形,則返回 true


bool font_is_force_autohinter(font_rid: RID) const 🔗

如果自動提示被支援且優先於字形內建提示,則返回 true。僅由動態字體使用。


bool font_is_language_supported(font_rid: RID, language: String) const 🔗

Returns true if the font supports the given language (as a ISO 639 code).


bool font_is_modulate_color_glyphs(font_rid: RID) const 🔗

Returns true if color modulation is applied when drawing the font's colored glyphs.


bool font_is_multichannel_signed_distance_field(font_rid: RID) const 🔗

如果使用從動態字形向量資料生成的單個多通道有符號距離場算繪所有大小的字形,則返回 true


bool font_is_script_supported(font_rid: RID, script: String) const 🔗

Returns true if the font supports the given script (as a ISO 15924 code).


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

從快取條目中移除指定的算繪字形資訊。

注意:這個函式不會移除與字形相關的紋理,請使用 font_remove_texture() 手動移除。


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

移除字形對的字距調整覆蓋。


void font_remove_language_support_override(font_rid: RID, language: String) 🔗

移除語言支援覆蓋。


void font_remove_script_support_override(font_rid: RID, script: String) 🔗

移除文字支援覆蓋。


void font_remove_size_cache(font_rid: RID, size: Vector2i) 🔗

從快取條目中移除指定的字形大小。


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

從快取條目中移除指定紋理。

注意:這個函式不會移除與紋理關聯的字形,請使用 font_remove_glyph() 手動移除。


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

將指定的字元算繪到字形快取紋理。


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

將範圍內的字元算繪到字形快取紋理。


void font_set_allow_system_fallback(font_rid: RID, allow_system_fallback: bool) 🔗

如果設定為 true,則可以自動將系統字形作為退回使用。


void font_set_antialiasing(font_rid: RID, antialiasing: FontAntialiasing) 🔗

使用字形抗鋸齒模式。


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

設定字形的升部(基線上方的圖元數)。


void font_set_baseline_offset(font_rid: RID, baseline_offset: float) 🔗

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


void font_set_data(font_rid: RID, data: PackedByteArray) 🔗

設定字形來源資料,例如動態字形的原始檔案內容。


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

設定字形的降部(基線下方的圖元數)。


void font_set_disable_embedded_bitmaps(font_rid: RID, disable_embedded_bitmaps: bool) 🔗

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


void font_set_embolden(font_rid: RID, strength: float) 🔗

設定字形的加粗強度。如果 strength 不等於零,則會加粗字形輪廓。負值會減小輪廓的粗細度。


void font_set_face_index(font_rid: RID, face_index: int) 🔗

在 TrueType / OpenType 集合中設定活動字形索引。


void font_set_fixed_size(font_rid: RID, fixed_size: int) 🔗

設定點陣字型的固定大小。如果設定為大於零的值,則會為所有字形大小使用相同的緩存條目。


void font_set_fixed_size_scale_mode(font_rid: RID, fixed_size_scale_mode: FixedSizeScaleMode) 🔗

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


void font_set_force_autohinter(font_rid: RID, force_autohinter: bool) 🔗

如果設定為 true,則優先使用自動微調,而不是字形的內建微調。


void font_set_generate_mipmaps(font_rid: RID, generate_mipmaps: bool) 🔗

如果設定為 true,則啟用字形紋理 mipmap 生成。


void font_set_global_oversampling(oversampling: float) 🔗

已棄用: Use Viewport oversampling, or the oversampling argument of the draw_* methods instead.

This method does nothing.


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

設定字形前進量(下一個字形的偏移量)。

注意:字形輪廓的前進量與基礎字形的前進量相同,不會被保存。


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

設定字形相對於基線的偏移量。


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

設定字形的大小。


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

設定包含該字形的快取紋理的索引。


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

設定包含該字形的快取紋理中,該字形的矩形區域。


void font_set_hinting(font_rid: RID, hinting: Hinting) 🔗

設定字形微調模式。僅由動態字形使用。


void font_set_keep_rounding_remainders(font_rid: RID, keep_rounding_remainders: 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_kerning(font_rid: RID, size: int, glyph_pair: Vector2i, kerning: Vector2) 🔗

設定字形對的字距調整。


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

font_is_language_supported() 新增覆蓋。


void font_set_modulate_color_glyphs(font_rid: RID, modulate: bool) 🔗

If set to true, color modulation is applied when drawing colored glyphs, otherwise it's applied to the monochrome glyphs only.


void font_set_msdf_pixel_range(font_rid: RID, msdf_pixel_range: int) 🔗

設定最小和最大可表示有符號距離之間形狀周圍範圍的寬度。


void font_set_msdf_size(font_rid: RID, msdf_size: int) 🔗

設定用於生成 MSDF 紋理的源字形大小。


void font_set_multichannel_signed_distance_field(font_rid: RID, msdf: bool) 🔗

如果設定為 true,則所有大小的字形都使用同一個從動態字形向量資料生成的多通道帶符號距離場進行算繪。MSDF 算繪能夠使用任意縮放係數顯示字形,字形不會變得模糊,字形大小的改變也不會消耗 CPU 的性能(因為字形不再需要在 CPU 上進行光柵化)。缺點是MSDF 無法使用字形微調。缺少字形微調時,銳度可能降低,較小的字形可能不易閱讀。

注意:MSDF 字形算繪無法正確算繪存在形狀重疊的字形。重疊的形狀在 OpenType 標準中是無效的,但在很多字形檔中仍然很常見,尤其是經過 Google Fonts 轉換後的那些。要避免形狀重疊帶來的問題,請考慮直接從字形廠商下載字形文件,不要依賴 Google Fonts。


void font_set_name(font_rid: RID, name: String) 🔗

設定該字形的家族名稱。


void font_set_opentype_feature_overrides(font_rid: RID, overrides: Dictionary) 🔗

設定字形 OpenType 功能集覆蓋。


void font_set_oversampling(font_rid: RID, oversampling: float) 🔗

If set to a positive value, overrides the oversampling factor of the viewport this font is used in. See Viewport.oversampling. This value doesn't override the oversampling parameter of draw_* methods. Used by dynamic fonts only.


void font_set_palette_custom_colors(font_rid: RID, colors: PackedColorArray) 🔗

Sets array of custom colors to override predefined palette. Set to empty array to reset overrides. Use Color(0, 0, 0, 0), to keep predefined palette color at specific position.


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

設定彩色點陣字型的縮放係數。


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

font_is_script_supported() 新增覆蓋。


void font_set_spacing(font_rid: RID, spacing: SpacingType, value: int) 🔗

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


void font_set_stretch(font_rid: RID, weight: int) 🔗

設定字形相對於普通寬度的拉伸量,是在 50%200% 之間的百分比值。

注意:這個值僅用於配對字形,不會影響字形的算繪。請改用 font_set_face_index()font_set_variation_coordinates()font_set_transform()


void font_set_style(font_rid: RID, style: BitField[FontStyle]) 🔗

Sets the font style flags.

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


void font_set_style_name(font_rid: RID, name: String) 🔗

設定字形的樣式名稱。


void font_set_subpixel_positioning(font_rid: RID, subpixel_positioning: SubpixelPositioning) 🔗

設定字形的次圖元字形定位模式。


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

設定字形的快取紋理圖像資料。


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

設定包含字形打包資料的陣列。


void font_set_transform(font_rid: RID, transform: 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_underline_position(font_rid: RID, size: int, underline_position: float) 🔗

設定基線下方底線的圖元偏移。


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

設定底線的粗細度,單位為圖元。


void font_set_used_palette(font_rid: RID, index: int) 🔗

Sets used palette index.


void font_set_variation_coordinates(font_rid: RID, variation_coordinates: Dictionary) 🔗

為指定的字形快取條目設定變體座標。詳見 font_supported_variation_list()


void font_set_weight(font_rid: RID, weight: int) 🔗

設定字形的字重(粗度)。字重是在 100...999 範圍內的值,普通字重為 400,粗體字重為 700

注意:這個值僅用於配對字形,不會影響字形的算繪。請改用 font_set_face_index()font_set_variation_coordinates()font_set_embolden()font_set_transform()


Dictionary font_supported_feature_list(font_rid: RID) const 🔗

返回支援的 OpenType 功能的字典。


Dictionary font_supported_variation_list(font_rid: RID) const 🔗

返回支援的 OpenType 變體座標的字典。


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

已棄用: Use TranslationServer.format_number() instead.

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

If language is an empty string, the active locale will be used.


void free_rid(rid: RID) 🔗

釋放由該 TextServer 建立的某個對象。


int get_features() const 🔗

返回文字伺服器的功能,見 Feature


Vector2 get_hex_code_box_size(size: int, index: int) const 🔗

返回替換字元的大小(在無效字元處繪製的帶十六進位字元程式碼的框)。


String get_name() const 🔗

返回該伺服器介面的名稱。


PackedByteArray get_support_data() const 🔗

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


String get_support_data_filename() const 🔗

返回預設的 TextServer 資料庫(例如 ICU 中斷反覆運算器和字典)檔案名。


String get_support_data_info() const 🔗

返回 TextServer 資料庫(例如 ICU 中斷反覆運算器和字典)的描述。


bool has(rid: RID) 🔗

如果 rid 是該文字伺服器擁有的有效資源,則返回 true


bool has_feature(feature: Feature) const 🔗

如果伺服器支援某個功能,則返回 true


int is_confusable(string: String, dict: PackedStringArray) const 🔗

返回 dict 中可能與 string 發生視覺混淆的第一個字串的索引,如果沒有找到則返回 -1

注意:這個方法不偵測不可見字元,要進行欺騙性偵測,請與 spoof_check() 結合使用。

注意:如果該伺服器不支援 FEATURE_UNICODE_SECURITY 功能,則始終返回 -1


bool is_locale_right_to_left(locale: String) const 🔗

如果區域設定為從右至左,則返回 true


bool is_locale_using_support_data(locale: String) const 🔗

Returns true if the locale requires text server support data for line/word breaking.


bool is_valid_identifier(string: String) const 🔗

如果 string 為有效的識別字,則返回 true

如果文字伺服器支援 FEATURE_UNICODE_IDENTIFIERS 功能,則有效的標識符必須:

  • 遵循 C 範式。

  • 開頭是 XID_Start 類的 Unicode 字元或 "_"

  • 其他位置可以包含 XID_Continue 類的 Unicode 字元。

  • 僅使用 UAX #31 推薦的文字(允許混合文字)。

如果不支援 FEATURE_UNICODE_IDENTIFIERS 功能,則有效的識別字必須:

  • 開頭是 XID_Start 類的 Unicode 字元或 "_"

  • 其他位置可以包含 XID_Continue 類的 Unicode 字元。


bool is_valid_letter(unicode: int) const 🔗

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


bool load_support_data(filename: String) 🔗

載入可選的 TextServer 資料庫(例如 ICU 斷字反覆運算器和字典)。

注意:這個函式應該在使用任何其他 TextServer 函式之前呼叫,否則不會起任何作用。


int name_to_tag(name: String) const 🔗

Converts the given readable name of a feature, variation, script, or language to an OpenType tag.


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

已棄用: Use TranslationServer.parse_number() instead.

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

If language is an empty string, the active locale will be used.


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

Default implementation of the BiDi algorithm override function.


String percent_sign(language: String = "") const 🔗

已棄用: Use TranslationServer.get_percent_sign() instead.

Returns the percent sign used in the given language.

If language is an empty string, the active locale will be used.


bool save_support_data(filename: String) const 🔗

將可選的 TextServer 資料庫(例如 ICU 斷字反覆運算器和字典)保存到檔中。

注意:這個函式在匯出專案時會用到,用於包含 TextServer 資料庫。


int shaped_get_run_count(shaped: RID) const 🔗

Returns the number of uniform text runs in the buffer.


Direction shaped_get_run_direction(shaped: RID, index: int) const 🔗

Returns the direction of the index text run (in visual order).


RID shaped_get_run_font_rid(shaped: RID, index: int) const 🔗

Returns the font RID of the index text run (in visual order).


int shaped_get_run_font_size(shaped: RID, index: int) const 🔗

Returns the font size of the index text run (in visual order).


Vector2i shaped_get_run_glyph_range(shaped: RID, index: int) const 🔗

Returns the glyph range of the index text run (in visual order).


String shaped_get_run_language(shaped: RID, index: int) const 🔗

Returns the language of the index text run (in visual order).


Variant shaped_get_run_object(shaped: RID, index: int) const 🔗

Returns the embedded object of the index text run (in visual order).


Vector2i shaped_get_run_range(shaped: RID, index: int) const 🔗

Returns the source text range of the index text run (in visual order).


String shaped_get_run_text(shaped: RID, index: int) const 🔗

Returns the source text of the index text run (in visual order).


int shaped_get_span_count(shaped: RID) const 🔗

返回使用 shaped_text_add_string()shaped_text_add_object() 新增的文字區間的數量。


Variant shaped_get_span_embedded_object(shaped: RID, index: int) const 🔗

Returns text embedded object key.


Variant shaped_get_span_meta(shaped: RID, index: int) const 🔗

返回文字區間的中繼資料。


Variant shaped_get_span_object(shaped: RID, index: int) const 🔗

Returns the text span embedded object key.


String shaped_get_span_text(shaped: RID, index: int) const 🔗

Returns the text span source text.


String shaped_get_text(shaped: RID) const 🔗

Returns the text buffer source text, including object replacement characters.


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

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


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

向文字緩衝中新增行內物件,key 必須唯一。在文字中,物件使用 length 個物件替換字元表示。


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

新增文字區間和字形,將其繪製到文字緩衝中。


void shaped_text_clear(rid: RID) 🔗

清空文字緩衝(移除文字和行內物件)。


int shaped_text_closest_character_pos(shaped: RID, pos: int) const 🔗

返回距離 pos 最近的組合字元結束位置。


void shaped_text_draw(shaped: RID, canvas: RID, pos: Vector2, clip_l: float = -1, clip_r: float = -1, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) 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). If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.

clip_l and clip_r are offsets relative to pos, going to the right in horizontal layout and downward in vertical layout. If clip_l is not negative, glyphs starting before the offset are clipped. If clip_r is not negative, glyphs ending after the offset are clipped.


void shaped_text_draw_outline(shaped: RID, canvas: RID, pos: Vector2, clip_l: float = -1, clip_r: float = -1, outline_size: int = 1, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) 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). If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.

clip_l and clip_r are offsets relative to pos, going to the right in horizontal layout and downward in vertical layout. If clip_l is not negative, glyphs starting before the offset are clipped. If clip_r is not negative, glyphs ending after the offset are clipped.


RID shaped_text_duplicate(rid: RID) 🔗

Duplicates shaped text buffer.


float shaped_text_fit_to_width(shaped: RID, width: float, justification_flags: BitField[JustificationFlag] = 3) 🔗

兩端對齊文字以適合指定寬度,返回新的文字寬度。


float shaped_text_get_ascent(shaped: RID) const 🔗

返回文字上高(水平佈局基線上方的圖元數,或垂直佈局基線左側的圖元數)。

注意:如果某些字形偏離基線,則總體上高可能高於字形上高。


Dictionary shaped_text_get_carets(shaped: RID, position: int) const 🔗

返回與文字中字元偏移 position 對應的文字游標的形狀。返回的游標形狀是寬度為 1 圖元的矩形。


PackedInt32Array shaped_text_get_character_breaks(shaped: RID) const 🔗

返回字形快取條目的數量。


int shaped_text_get_custom_ellipsis(shaped: RID) const 🔗

Returns ellipsis character used for text clipping.


String shaped_text_get_custom_punctuation(shaped: RID) const 🔗

返回自訂標點字元列表,用於斷字。如果被設定為空字串,則使用服務的預設值。


float shaped_text_get_descent(shaped: RID) const 🔗

返回文字下深(水平佈局基線下方的圖元數,或垂直佈局基線右側的圖元數)。

注意:如果某些字形偏離基線,則總體下深可能高於字形下深。


Direction shaped_text_get_direction(shaped: RID) const 🔗

返回文字的方向。


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

返回文字範圍內的主要書寫方向。


int shaped_text_get_ellipsis_glyph_count(shaped: RID) const 🔗

返回省略號中的字形數。


Array[Dictionary] shaped_text_get_ellipsis_glyphs(shaped: RID) const 🔗

返回省略號中的字形陣列。


int shaped_text_get_ellipsis_pos(shaped: RID) const 🔗

返回省略號的位置。


int shaped_text_get_glyph_count(shaped: RID) const 🔗

返回緩衝區中的字形數。


Array[Dictionary] shaped_text_get_glyphs(shaped: RID) const 🔗

返回字形陣列,按視覺順序排序。


Vector2 shaped_text_get_grapheme_bounds(shaped: RID, pos: int) const 🔗

將複合字元的邊界返回為距行首的偏移量。


Direction shaped_text_get_inferred_direction(shaped: RID) const 🔗

返回由 BiDi 演算法推斷的文字書寫方向。


PackedInt32Array shaped_text_get_line_breaks(shaped: RID, width: float, start: int = 0, break_flags: BitField[LineBreakFlag] = 3) const 🔗

對文字進行斷行,返回每一行的字元範圍。


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

將文字拆分為行和列。返回每段的字元範圍。


int shaped_text_get_object_glyph(shaped: RID, key: Variant) const 🔗

Returns the glyph index of the inline object.


Vector2i shaped_text_get_object_range(shaped: RID, key: Variant) const 🔗

Returns the character range of the inline object.


Rect2 shaped_text_get_object_rect(shaped: RID, key: Variant) const 🔗

返回行內對象的邊界矩形。


Array shaped_text_get_objects(shaped: RID) const 🔗

返回行內物件的陣列。


Orientation shaped_text_get_orientation(shaped: RID) const 🔗

返回文字朝向。


RID shaped_text_get_parent(shaped: RID) const 🔗

返回子字串源自哪個父緩衝區。


bool shaped_text_get_preserve_control(shaped: RID) const 🔗

如果文字緩衝區被配置為顯示控制字元,則返回 true


bool shaped_text_get_preserve_invalid(shaped: RID) const 🔗

如果文字緩衝區被配置為在無效字元處顯示十六進位程式碼,則返回 true

注意:如果設定為 false,則在無效字元處不顯示任何內容。


Vector2i shaped_text_get_range(shaped: RID) const 🔗

返回父緩衝區中子字串緩衝區的字元範圍。


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

返回用於指定字元範圍的選區矩形。


Vector2 shaped_text_get_size(shaped: RID) const 🔗

返回該文字的大小。


int shaped_text_get_spacing(shaped: RID, spacing: SpacingType) const 🔗

返回字形或行之間新增的額外間距,單位為圖元。


int shaped_text_get_trim_pos(shaped: RID) const 🔗

返回超出修剪的位置。


float shaped_text_get_underline_position(shaped: RID) const 🔗

返回基線下方底線的圖元偏移。


float shaped_text_get_underline_thickness(shaped: RID) const 🔗

返回底線的粗細度。


float shaped_text_get_width(shaped: RID) const 🔗

返回文字的寬度(對於水平排版)或高度(對於垂直排版)。


PackedInt32Array shaped_text_get_word_breaks(shaped: RID, grapheme_flags: BitField[GraphemeFlag] = 264, skip_grapheme_flags: BitField[GraphemeFlag] = 4) const 🔗

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


bool shaped_text_has_object(shaped: RID, key: Variant) const 🔗

Returns true if an object with key is embedded in this shaped text buffer.


bool shaped_text_has_visible_chars(shaped: RID) const 🔗

如果文字緩衝區存在可顯示字元,則返回 true


int shaped_text_hit_test_grapheme(shaped: RID, coords: float) const 🔗

返回字素的索引,該字素位於基線上指定圖元偏移的位置,如果沒有找到,則返回 -1


int shaped_text_hit_test_position(shaped: RID, coords: float) const 🔗

返回基線處指定圖元偏移處的文字游標的偏移量。該函式始終返回一個有效位置。


bool shaped_text_is_ready(shaped: RID) const 🔗

如果緩衝區成功塑形,則返回 true


int shaped_text_next_character_pos(shaped: RID, pos: int) const 🔗

返回距離 pos 最近的組合字元結束位置。


int shaped_text_next_grapheme_pos(shaped: RID, pos: int) const 🔗

返回距離 pos 最近的組合字元結束位置。


void shaped_text_overrun_trim_to_width(shaped: RID, width: float = 0, overrun_trim_flags: BitField[TextOverrunFlag] = 0) 🔗

如果文字超出給定寬度,則修剪文字。


int shaped_text_prev_character_pos(shaped: RID, pos: int) const 🔗

返回距離 pos 最近的組合字元開始位置。


int shaped_text_prev_grapheme_pos(shaped: RID, pos: int) const 🔗

返回距離 pos 最近的組合字元開始位置。


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

設定內嵌物件的新大小和對齊方式。


void shaped_text_set_bidi_override(shaped: RID, override: Array) 🔗

覆蓋用於結構化文字的 BiDi。

覆蓋範圍應覆蓋完整的源文字而沒有重疊。BiDi 演算法將分別被用於每個範圍。


void shaped_text_set_custom_ellipsis(shaped: RID, char: int) 🔗

Sets ellipsis character used for text clipping.


void shaped_text_set_custom_punctuation(shaped: RID, punct: String) 🔗

設定自訂標點字元列表,用於斷字。如果被設定為空字串,則使用服務的預設值。


void shaped_text_set_direction(shaped: RID, direction: Direction = 0) 🔗

設定所需的文字方向。如果設定為 DIRECTION_AUTO,方向將根據緩衝區的內容和目前的區域設定來偵測。

注意:如果伺服器不支援 FEATURE_BIDI_LAYOUT 功能,則方向會被忽略(TextServerAdvanced 支援)。


void shaped_text_set_orientation(shaped: RID, orientation: Orientation = 0) 🔗

設定所需的文字排版方向。

注意:如果服務不支援 FEATURE_VERTICAL_LAYOUT 功能(由 TextServerAdvanced 支援),則排版方向將被忽略。


void shaped_text_set_preserve_control(shaped: RID, enabled: bool) 🔗

如果設定為 true,則文字緩衝區將顯示控制字元。


void shaped_text_set_preserve_invalid(shaped: RID, enabled: bool) 🔗

如果設定為 true,則文字緩衝區會將無效字元顯示為十六進位程式碼,否則不顯示任何內容。


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

設定字形之間或行與行之間新增的額外圖元間距。


bool shaped_text_shape(shaped: RID) 🔗

形狀緩衝區(如果未整形)。如果字串整形成功,則返回 true

注意:無需手動呼叫該函式,只要請求其任何輸出資料,緩衝區就會自動被整形。


Array[Dictionary] shaped_text_sort_logical(shaped: RID) 🔗

按邏輯順序返回文字字形。


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

返回 shaped 文字緩衝區中字串的子字串的文字緩衝區(包括行內對象)。


float shaped_text_tab_align(shaped: RID, tab_stops: PackedFloat32Array) 🔗

將塑形文字與給定的定位停駐點對齊。


bool spoof_check(string: String) const 🔗

如果 string 可能造成讀者的混淆,則返回 true

注意:如果伺服器不支援 FEATURE_UNICODE_SECURITY 功能,則始終返回 false


PackedInt32Array string_get_character_breaks(string: String, language: String = "") 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_word_breaks(string: String, language: String = "", chars_per_line: int = 0) const 🔗

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

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

var ts = TextServerManager.get_primary_interface()
# 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]

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

Returns the string converted to lowercase.

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

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


String string_to_title(string: String, language: String = "") const 🔗

Returns the string converted to Title Case.

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

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


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

Returns the string converted to UPPERCASE.

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

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


String strip_diacritics(string: String) const 🔗

從字串中剝離變音符號。

注意:得到的字串可能比原來的更長,也可能更短。


String tag_to_name(tag: int) const 🔗

Converts the given OpenType tag to the readable name of a feature, variation, script, or language.