Struct TextServer
pub struct TextServer { /* private fields */ }Expand description
Godot class TextServer.
Inherits RefCounted.
Related symbols:
text_server: sidecar module with related enum/flag types
See also Godot docs for TextServer.
§Not instantiable
This class cannot be constructed. Obtain Gd<TextServer> instances via Godot APIs.
§Final class
This class is final, meaning you cannot inherit from it, and it comes without I* interface trait. It is still possible that other Godot classes inherit from it, but that is limited to the engine itself.
§Godot docs
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()Implementations§
§impl TextServer
impl TextServer
pub fn has_feature(&self, feature: Feature) -> bool
pub fn has_feature(&self, feature: Feature) -> bool
Returns true if the server supports a feature.
pub fn get_features(&self) -> i64
pub fn get_features(&self) -> i64
Returns text server features, see [enum Feature].
pub fn load_support_data(&mut self, filename: impl AsArg<GString>) -> bool
pub fn load_support_data(&mut self, filename: impl AsArg<GString>) -> bool
Loads optional TextServer database (e.g. ICU break iterators and dictionaries).
Note: This function should be called before any other TextServer functions used, otherwise it won’t have any effect.
pub fn get_support_data_filename(&self) -> GString
pub fn get_support_data_filename(&self) -> GString
Returns default TextServer database (e.g. ICU break iterators and dictionaries) filename.
pub fn get_support_data_info(&self) -> GString
pub fn get_support_data_info(&self) -> GString
Returns TextServer database (e.g. ICU break iterators and dictionaries) description.
pub fn save_support_data(&self, filename: impl AsArg<GString>) -> bool
pub fn save_support_data(&self, filename: impl AsArg<GString>) -> bool
Saves optional TextServer database (e.g. ICU break iterators and dictionaries) to the file.
Note: This function is used by during project export, to include TextServer database.
pub fn get_support_data(&self) -> PackedArray<u8>
pub fn get_support_data(&self) -> PackedArray<u8>
Returns default TextServer database (e.g. ICU break iterators and dictionaries).
pub fn is_locale_using_support_data(&self, locale: impl AsArg<GString>) -> bool
pub fn is_locale_using_support_data(&self, locale: impl AsArg<GString>) -> bool
Returns true if the locale requires text server support data for line/word breaking.
pub fn is_locale_right_to_left(&self, locale: impl AsArg<GString>) -> bool
pub fn is_locale_right_to_left(&self, locale: impl AsArg<GString>) -> bool
Returns true if locale is right-to-left.
pub fn name_to_tag(&self, name: impl AsArg<GString>) -> i64
pub fn name_to_tag(&self, name: impl AsArg<GString>) -> i64
Converts the given readable name of a feature, variation, script, or language to an OpenType tag.
pub fn tag_to_name(&self, tag: i64) -> GString
pub fn tag_to_name(&self, tag: i64) -> GString
Converts the given OpenType tag to the readable name of a feature, variation, script, or language.
pub fn has(&mut self, rid: Rid) -> bool
pub fn has(&mut self, rid: Rid) -> bool
Returns true if rid is valid resource owned by this text server.
pub fn create_font(&mut self) -> Rid
pub fn create_font(&mut self) -> Rid
Creates a new, empty font cache entry resource. To free the resulting resource, use the free_rid method.
pub fn create_font_linked_variation(&mut self, font_rid: Rid) -> Rid
pub fn create_font_linked_variation(&mut self, font_rid: 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.
pub fn font_set_data(&mut self, font_rid: Rid, data: &PackedArray<u8>)
pub fn font_set_data(&mut self, font_rid: Rid, data: &PackedArray<u8>)
Sets font source data, e.g contents of the dynamic font source file.
pub fn font_set_face_index(&mut self, font_rid: Rid, face_index: i64)
pub fn font_set_face_index(&mut self, font_rid: Rid, face_index: i64)
Sets an active face index in the TrueType / OpenType collection.
pub fn font_get_face_index(&self, font_rid: Rid) -> i64
pub fn font_get_face_index(&self, font_rid: Rid) -> i64
Returns an active face index in the TrueType / OpenType collection.
pub fn font_get_face_count(&self, font_rid: Rid) -> i64
pub fn font_get_face_count(&self, font_rid: Rid) -> i64
Returns number of faces in the TrueType / OpenType collection.
pub fn font_set_style(&mut self, font_rid: Rid, style: FontStyle)
pub fn font_set_style(&mut self, font_rid: Rid, style: 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.
pub fn font_get_style(&self, font_rid: Rid) -> FontStyle
pub fn font_get_style(&self, font_rid: Rid) -> FontStyle
Returns font style flags.
pub fn font_set_name(&mut self, font_rid: Rid, name: impl AsArg<GString>)
pub fn font_set_name(&mut self, font_rid: Rid, name: impl AsArg<GString>)
Sets the font family name.
pub fn font_get_name(&self, font_rid: Rid) -> GString
pub fn font_get_name(&self, font_rid: Rid) -> GString
Returns font family name.
pub fn font_get_ot_name_strings(
&self,
font_rid: Rid,
) -> Dictionary<Variant, Variant>
pub fn font_get_ot_name_strings( &self, font_rid: Rid, ) -> Dictionary<Variant, Variant>
Returns Dictionary with OpenType font name strings (localized font names, version, description, license information, sample text, etc.).
pub fn font_set_style_name(&mut self, font_rid: Rid, name: impl AsArg<GString>)
pub fn font_set_style_name(&mut self, font_rid: Rid, name: impl AsArg<GString>)
Sets the font style name.
pub fn font_get_style_name(&self, font_rid: Rid) -> GString
pub fn font_get_style_name(&self, font_rid: Rid) -> GString
Returns font style name.
pub fn font_set_weight(&mut self, font_rid: Rid, weight: i64)
pub fn font_set_weight(&mut self, font_rid: Rid, weight: i64)
Sets weight (boldness) of the font. A value in the 100...999 range, normal font weight is 400, bold font weight is 700.
Note: This value is used for font matching only and will not affect font rendering. Use font_set_face_index, font_set_variation_coordinates, or font_set_embolden instead.
pub fn font_get_weight(&self, font_rid: Rid) -> i64
pub fn font_get_weight(&self, font_rid: Rid) -> i64
Returns weight (boldness) of the font. A value in the 100...999 range, normal font weight is 400, bold font weight is 700.
pub fn font_set_stretch(&mut self, font_rid: Rid, weight: i64)
pub fn font_set_stretch(&mut self, font_rid: Rid, weight: i64)
Sets font stretch amount, compared to a normal width. A percentage value between 50% and 200%.
Note: This value is used for font matching only and will not affect font rendering. Use font_set_face_index, font_set_variation_coordinates, or font_set_transform instead.
pub fn font_get_stretch(&self, font_rid: Rid) -> i64
pub fn font_get_stretch(&self, font_rid: Rid) -> i64
Returns font stretch amount, compared to a normal width. A percentage value between 50% and 200%.
pub fn font_set_antialiasing(
&mut self,
font_rid: Rid,
antialiasing: FontAntialiasing,
)
pub fn font_set_antialiasing( &mut self, font_rid: Rid, antialiasing: FontAntialiasing, )
Sets font anti-aliasing mode.
pub fn font_get_antialiasing(&self, font_rid: Rid) -> FontAntialiasing
pub fn font_get_antialiasing(&self, font_rid: Rid) -> FontAntialiasing
Returns font anti-aliasing mode.
pub fn font_set_disable_embedded_bitmaps(
&mut self,
font_rid: Rid,
disable_embedded_bitmaps: bool,
)
pub fn font_set_disable_embedded_bitmaps( &mut self, 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).
pub fn font_get_disable_embedded_bitmaps(&self, font_rid: Rid) -> bool
pub fn font_get_disable_embedded_bitmaps(&self, font_rid: Rid) -> bool
Returns whether the font’s embedded bitmap loading is disabled.
pub fn font_set_generate_mipmaps(
&mut self,
font_rid: Rid,
generate_mipmaps: bool,
)
pub fn font_set_generate_mipmaps( &mut self, font_rid: Rid, generate_mipmaps: bool, )
If set to true font texture mipmap generation is enabled.
pub fn font_get_generate_mipmaps(&self, font_rid: Rid) -> bool
pub fn font_get_generate_mipmaps(&self, font_rid: Rid) -> bool
Returns true if font texture mipmap generation is enabled.
pub fn font_set_multichannel_signed_distance_field(
&mut self,
font_rid: Rid,
msdf: bool,
)
pub fn font_set_multichannel_signed_distance_field( &mut self, font_rid: Rid, msdf: bool, )
If set to true, glyphs of all sizes are rendered using single multichannel signed distance field generated from the dynamic font vector data. MSDF rendering allows displaying the font at any scaling factor without blurriness, and without incurring a CPU cost when the font size changes (since the font no longer needs to be rasterized on the CPU). As a downside, font hinting is not available with MSDF. The lack of font hinting may result in less crisp and less readable fonts at small sizes.
Note: MSDF font rendering does not render glyphs with overlapping shapes correctly. Overlapping shapes are not valid per the OpenType standard, but are still commonly found in many font files, especially those converted by Google Fonts. To avoid issues with overlapping glyphs, consider downloading the font file directly from the type foundry instead of relying on Google Fonts.
pub fn font_is_multichannel_signed_distance_field(&self, font_rid: Rid) -> bool
pub fn font_is_multichannel_signed_distance_field(&self, font_rid: Rid) -> bool
Returns true if glyphs of all sizes are rendered using single multichannel signed distance field generated from the dynamic font vector data.
pub fn font_set_msdf_pixel_range(
&mut self,
font_rid: Rid,
msdf_pixel_range: i64,
)
pub fn font_set_msdf_pixel_range( &mut self, font_rid: Rid, msdf_pixel_range: i64, )
Sets the width of the range around the shape between the minimum and maximum representable signed distance.
pub fn font_get_msdf_pixel_range(&self, font_rid: Rid) -> i64
pub fn font_get_msdf_pixel_range(&self, font_rid: Rid) -> i64
Returns the width of the range around the shape between the minimum and maximum representable signed distance.
pub fn font_set_msdf_size(&mut self, font_rid: Rid, msdf_size: i64)
pub fn font_set_msdf_size(&mut self, font_rid: Rid, msdf_size: i64)
Sets source font size used to generate MSDF textures.
pub fn font_get_msdf_size(&self, font_rid: Rid) -> i64
pub fn font_get_msdf_size(&self, font_rid: Rid) -> i64
Returns source font size used to generate MSDF textures.
pub fn font_set_fixed_size(&mut self, font_rid: Rid, fixed_size: i64)
pub fn font_set_fixed_size(&mut self, font_rid: Rid, fixed_size: i64)
Sets bitmap font fixed size. If set to value greater than zero, same cache entry will be used for all font sizes.
pub fn font_get_fixed_size(&self, font_rid: Rid) -> i64
pub fn font_get_fixed_size(&self, font_rid: Rid) -> i64
Returns bitmap font fixed size.
pub fn font_set_fixed_size_scale_mode(
&mut self,
font_rid: Rid,
fixed_size_scale_mode: FixedSizeScaleMode,
)
pub fn font_set_fixed_size_scale_mode( &mut self, 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.
pub fn font_get_fixed_size_scale_mode(
&self,
font_rid: Rid,
) -> FixedSizeScaleMode
pub fn font_get_fixed_size_scale_mode( &self, font_rid: Rid, ) -> FixedSizeScaleMode
Returns bitmap font scaling mode.
pub fn font_set_allow_system_fallback(
&mut self,
font_rid: Rid,
allow_system_fallback: bool,
)
pub fn font_set_allow_system_fallback( &mut self, font_rid: Rid, allow_system_fallback: bool, )
If set to true, system fonts can be automatically used as fallbacks.
pub fn font_is_allow_system_fallback(&self, font_rid: Rid) -> bool
pub fn font_is_allow_system_fallback(&self, font_rid: Rid) -> bool
Returns true if system fonts can be automatically used as fallbacks.
pub fn font_clear_system_fallback_cache(&mut self)
pub fn font_clear_system_fallback_cache(&mut self)
Frees all automatically loaded system fonts.
pub fn font_set_force_autohinter(
&mut self,
font_rid: Rid,
force_autohinter: bool,
)
pub fn font_set_force_autohinter( &mut self, font_rid: Rid, force_autohinter: bool, )
If set to true auto-hinting is preferred over font built-in hinting.
pub fn font_is_force_autohinter(&self, font_rid: Rid) -> bool
pub fn font_is_force_autohinter(&self, font_rid: Rid) -> bool
Returns true if auto-hinting is supported and preferred over font built-in hinting. Used by dynamic fonts only.
pub fn font_set_modulate_color_glyphs(
&mut self,
font_rid: Rid,
force_autohinter: bool,
)
pub fn font_set_modulate_color_glyphs( &mut self, font_rid: Rid, force_autohinter: bool, )
If set to true, color modulation is applied when drawing colored glyphs, otherwise it’s applied to the monochrome glyphs only.
pub fn font_is_modulate_color_glyphs(&self, font_rid: Rid) -> bool
pub fn font_is_modulate_color_glyphs(&self, font_rid: Rid) -> bool
Returns true if color modulation is applied when drawing the font’s colored glyphs.
pub fn font_set_hinting(&mut self, font_rid: Rid, hinting: Hinting)
pub fn font_set_hinting(&mut self, font_rid: Rid, hinting: Hinting)
Sets font hinting mode. Used by dynamic fonts only.
pub fn font_get_hinting(&self, font_rid: Rid) -> Hinting
pub fn font_get_hinting(&self, font_rid: Rid) -> Hinting
Returns the font hinting mode. Used by dynamic fonts only.
pub fn font_set_subpixel_positioning(
&mut self,
font_rid: Rid,
subpixel_positioning: SubpixelPositioning,
)
pub fn font_set_subpixel_positioning( &mut self, font_rid: Rid, subpixel_positioning: SubpixelPositioning, )
Sets font subpixel glyph positioning mode.
pub fn font_get_subpixel_positioning(
&self,
font_rid: Rid,
) -> SubpixelPositioning
pub fn font_get_subpixel_positioning( &self, font_rid: Rid, ) -> SubpixelPositioning
Returns font subpixel glyph positioning mode.
pub fn font_set_keep_rounding_remainders(
&mut self,
font_rid: Rid,
keep_rounding_remainders: bool,
)
pub fn font_set_keep_rounding_remainders( &mut self, 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.
pub fn font_get_keep_rounding_remainders(&self, font_rid: Rid) -> bool
pub fn font_get_keep_rounding_remainders(&self, font_rid: Rid) -> bool
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.
pub fn font_set_embolden(&mut self, font_rid: Rid, strength: f64)
pub fn font_set_embolden(&mut self, font_rid: Rid, strength: f64)
Sets font embolden strength. If strength is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
pub fn font_get_embolden(&self, font_rid: Rid) -> f64
pub fn font_get_embolden(&self, font_rid: Rid) -> f64
Returns font embolden strength.
pub fn font_set_spacing(
&mut self,
font_rid: Rid,
spacing: SpacingType,
value: i64,
)
pub fn font_set_spacing( &mut self, font_rid: Rid, spacing: SpacingType, value: i64, )
Sets the spacing for spacing to value in pixels (not relative to the font size).
pub fn font_get_spacing(&self, font_rid: Rid, spacing: SpacingType) -> i64
pub fn font_get_spacing(&self, font_rid: Rid, spacing: SpacingType) -> i64
Returns the spacing for spacing in pixels (not relative to the font size).
pub fn font_set_baseline_offset(&mut self, font_rid: Rid, baseline_offset: f64)
pub fn font_set_baseline_offset(&mut self, font_rid: Rid, baseline_offset: f64)
Sets extra baseline offset (as a fraction of font height).
pub fn font_get_baseline_offset(&self, font_rid: Rid) -> f64
pub fn font_get_baseline_offset(&self, font_rid: Rid) -> f64
Returns extra baseline offset (as a fraction of font height).
pub fn font_set_transform(&mut self, font_rid: Rid, transform: Transform2D)
pub fn font_set_transform(&mut self, 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).
pub fn font_get_transform(&self, font_rid: Rid) -> Transform2D
pub fn font_get_transform(&self, font_rid: Rid) -> Transform2D
Returns 2D transform applied to the font outlines.
pub fn font_set_variation_coordinates(
&mut self,
font_rid: Rid,
variation_coordinates: &AnyDictionary,
)
pub fn font_set_variation_coordinates( &mut self, font_rid: Rid, variation_coordinates: &AnyDictionary, )
Sets variation coordinates for the specified font cache entry. See font_supported_variation_list for more info.
pub fn font_get_variation_coordinates(
&self,
font_rid: Rid,
) -> Dictionary<Variant, Variant>
pub fn font_get_variation_coordinates( &self, font_rid: Rid, ) -> Dictionary<Variant, Variant>
Returns variation coordinates for the specified font cache entry. See font_supported_variation_list for more info.
pub fn font_set_oversampling(&mut self, font_rid: Rid, oversampling: f64)
pub fn font_set_oversampling(&mut self, font_rid: Rid, oversampling: f64)
If set to a positive value, overrides the oversampling factor of the viewport this font is used in. See [member Viewport.oversampling]. This value doesn’t override the oversampling parameter of draw_* methods. Used by dynamic fonts only.
pub fn font_get_oversampling(&self, font_rid: Rid) -> f64
pub fn font_get_oversampling(&self, font_rid: Rid) -> f64
Returns oversampling factor override. If set to a positive value, overrides the oversampling factor of the viewport this font is used in. See [member Viewport.oversampling]. This value doesn’t override the oversampling parameter of draw_* methods. Used by dynamic fonts only.
pub fn font_get_size_cache_list(&self, font_rid: Rid) -> Array<Vector2i>
pub fn font_get_size_cache_list(&self, font_rid: Rid) -> Array<Vector2i>
Returns list of the font sizes in the cache. Each size is Vector2i with font size and outline size.
pub fn font_clear_size_cache(&mut self, font_rid: Rid)
pub fn font_clear_size_cache(&mut self, font_rid: Rid)
Removes all font sizes from the cache entry.
pub fn font_remove_size_cache(&mut self, font_rid: Rid, size: Vector2i)
pub fn font_remove_size_cache(&mut self, font_rid: Rid, size: Vector2i)
Removes specified font size from the cache entry.
pub fn font_get_size_cache_info(
&self,
font_rid: Rid,
) -> Array<Dictionary<Variant, Variant>>
pub fn font_get_size_cache_info( &self, font_rid: Rid, ) -> Array<Dictionary<Variant, Variant>>
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.
pub fn font_set_ascent(&mut self, font_rid: Rid, size: i64, ascent: f64)
pub fn font_set_ascent(&mut self, font_rid: Rid, size: i64, ascent: f64)
Sets the font ascent (number of pixels above the baseline).
pub fn font_get_ascent(&self, font_rid: Rid, size: i64) -> f64
pub fn font_get_ascent(&self, font_rid: Rid, size: i64) -> f64
Returns the font ascent (number of pixels above the baseline).
pub fn font_set_descent(&mut self, font_rid: Rid, size: i64, descent: f64)
pub fn font_set_descent(&mut self, font_rid: Rid, size: i64, descent: f64)
Sets the font descent (number of pixels below the baseline).
pub fn font_get_descent(&self, font_rid: Rid, size: i64) -> f64
pub fn font_get_descent(&self, font_rid: Rid, size: i64) -> f64
Returns the font descent (number of pixels below the baseline).
pub fn font_set_underline_position(
&mut self,
font_rid: Rid,
size: i64,
underline_position: f64,
)
pub fn font_set_underline_position( &mut self, font_rid: Rid, size: i64, underline_position: f64, )
Sets pixel offset of the underline below the baseline.
pub fn font_get_underline_position(&self, font_rid: Rid, size: i64) -> f64
pub fn font_get_underline_position(&self, font_rid: Rid, size: i64) -> f64
Returns pixel offset of the underline below the baseline.
pub fn font_set_underline_thickness(
&mut self,
font_rid: Rid,
size: i64,
underline_thickness: f64,
)
pub fn font_set_underline_thickness( &mut self, font_rid: Rid, size: i64, underline_thickness: f64, )
Sets thickness of the underline in pixels.
pub fn font_get_underline_thickness(&self, font_rid: Rid, size: i64) -> f64
pub fn font_get_underline_thickness(&self, font_rid: Rid, size: i64) -> f64
Returns thickness of the underline in pixels.
pub fn font_set_scale(&mut self, font_rid: Rid, size: i64, scale: f64)
pub fn font_set_scale(&mut self, font_rid: Rid, size: i64, scale: f64)
Sets scaling factor of the color bitmap font.
pub fn font_get_scale(&self, font_rid: Rid, size: i64) -> f64
pub fn font_get_scale(&self, font_rid: Rid, size: i64) -> f64
Returns scaling factor of the color bitmap font.
pub fn font_get_texture_count(&self, font_rid: Rid, size: Vector2i) -> i64
pub fn font_get_texture_count(&self, font_rid: Rid, size: Vector2i) -> i64
Returns number of textures used by font cache entry.
pub fn font_clear_textures(&mut self, font_rid: Rid, size: Vector2i)
pub fn font_clear_textures(&mut self, font_rid: Rid, size: Vector2i)
Removes all textures from font cache entry.
Note: This function will not remove glyphs associated with the texture, use font_remove_glyph to remove them manually.
pub fn font_remove_texture(
&mut self,
font_rid: Rid,
size: Vector2i,
texture_index: i64,
)
pub fn font_remove_texture( &mut self, font_rid: Rid, size: Vector2i, texture_index: i64, )
Removes specified texture from the cache entry.
Note: This function will not remove glyphs associated with the texture, remove them manually, using font_remove_glyph.
pub fn font_set_texture_image(
&mut self,
font_rid: Rid,
size: Vector2i,
texture_index: i64,
image: impl AsArg<Option<Gd<Image>>>,
)
pub fn font_set_texture_image( &mut self, font_rid: Rid, size: Vector2i, texture_index: i64, image: impl AsArg<Option<Gd<Image>>>, )
Sets font cache texture image data.
pub fn font_get_texture_image(
&self,
font_rid: Rid,
size: Vector2i,
texture_index: i64,
) -> Option<Gd<Image>>
pub fn font_get_texture_image( &self, font_rid: Rid, size: Vector2i, texture_index: i64, ) -> Option<Gd<Image>>
Returns font cache texture image data.
pub fn font_set_texture_offsets(
&mut self,
font_rid: Rid,
size: Vector2i,
texture_index: i64,
offset: &PackedArray<i32>,
)
pub fn font_set_texture_offsets( &mut self, font_rid: Rid, size: Vector2i, texture_index: i64, offset: &PackedArray<i32>, )
Sets array containing glyph packing data.
pub fn font_get_texture_offsets(
&self,
font_rid: Rid,
size: Vector2i,
texture_index: i64,
) -> PackedArray<i32>
pub fn font_get_texture_offsets( &self, font_rid: Rid, size: Vector2i, texture_index: i64, ) -> PackedArray<i32>
Returns array containing glyph packing data.
pub fn font_get_glyph_list(
&self,
font_rid: Rid,
size: Vector2i,
) -> PackedArray<i32>
pub fn font_get_glyph_list( &self, font_rid: Rid, size: Vector2i, ) -> PackedArray<i32>
Returns list of rendered glyphs in the cache entry.
pub fn font_clear_glyphs(&mut self, font_rid: Rid, size: Vector2i)
pub fn font_clear_glyphs(&mut self, 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.
pub fn font_remove_glyph(&mut self, font_rid: Rid, size: Vector2i, glyph: i64)
pub fn font_remove_glyph(&mut self, font_rid: Rid, size: Vector2i, glyph: i64)
Removes specified 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.
pub fn font_get_glyph_advance(
&self,
font_rid: Rid,
size: i64,
glyph: i64,
) -> Vector2
pub fn font_get_glyph_advance( &self, font_rid: Rid, size: i64, glyph: i64, ) -> Vector2
Returns glyph advance (offset of the next glyph).
Note: Advance for glyphs outlines is the same as the base glyph advance and is not saved.
pub fn font_set_glyph_advance(
&mut self,
font_rid: Rid,
size: i64,
glyph: i64,
advance: Vector2,
)
pub fn font_set_glyph_advance( &mut self, font_rid: Rid, size: i64, glyph: i64, advance: Vector2, )
Sets glyph advance (offset of the next glyph).
Note: Advance for glyphs outlines is the same as the base glyph advance and is not saved.
pub fn font_get_glyph_offset(
&self,
font_rid: Rid,
size: Vector2i,
glyph: i64,
) -> Vector2
pub fn font_get_glyph_offset( &self, font_rid: Rid, size: Vector2i, glyph: i64, ) -> Vector2
Returns glyph offset from the baseline.
pub fn font_set_glyph_offset(
&mut self,
font_rid: Rid,
size: Vector2i,
glyph: i64,
offset: Vector2,
)
pub fn font_set_glyph_offset( &mut self, font_rid: Rid, size: Vector2i, glyph: i64, offset: Vector2, )
Sets glyph offset from the baseline.
pub fn font_get_glyph_size(
&self,
font_rid: Rid,
size: Vector2i,
glyph: i64,
) -> Vector2
pub fn font_get_glyph_size( &self, font_rid: Rid, size: Vector2i, glyph: i64, ) -> Vector2
Returns size of the glyph.
pub fn font_set_glyph_size(
&mut self,
font_rid: Rid,
size: Vector2i,
glyph: i64,
gl_size: Vector2,
)
pub fn font_set_glyph_size( &mut self, font_rid: Rid, size: Vector2i, glyph: i64, gl_size: Vector2, )
Sets size of the glyph.
pub fn font_get_glyph_uv_rect(
&self,
font_rid: Rid,
size: Vector2i,
glyph: i64,
) -> Rect2
pub fn font_get_glyph_uv_rect( &self, font_rid: Rid, size: Vector2i, glyph: i64, ) -> Rect2
Returns rectangle in the cache texture containing the glyph.
pub fn font_set_glyph_uv_rect(
&mut self,
font_rid: Rid,
size: Vector2i,
glyph: i64,
uv_rect: Rect2,
)
pub fn font_set_glyph_uv_rect( &mut self, font_rid: Rid, size: Vector2i, glyph: i64, uv_rect: Rect2, )
Sets rectangle in the cache texture containing the glyph.
pub fn font_get_glyph_texture_idx(
&self,
font_rid: Rid,
size: Vector2i,
glyph: i64,
) -> i64
pub fn font_get_glyph_texture_idx( &self, font_rid: Rid, size: Vector2i, glyph: i64, ) -> i64
Returns index of the cache texture containing the glyph.
pub fn font_set_glyph_texture_idx(
&mut self,
font_rid: Rid,
size: Vector2i,
glyph: i64,
texture_idx: i64,
)
pub fn font_set_glyph_texture_idx( &mut self, font_rid: Rid, size: Vector2i, glyph: i64, texture_idx: i64, )
Sets index of the cache texture containing the glyph.
pub fn font_get_glyph_texture_rid(
&self,
font_rid: Rid,
size: Vector2i,
glyph: i64,
) -> Rid
pub fn font_get_glyph_texture_rid( &self, font_rid: Rid, size: Vector2i, glyph: i64, ) -> Rid
Returns resource ID of the cache texture containing the glyph.
Note: If there are pending glyphs to render, calling this function might trigger the texture cache update.
pub fn font_get_glyph_texture_size(
&self,
font_rid: Rid,
size: Vector2i,
glyph: i64,
) -> Vector2
pub fn font_get_glyph_texture_size( &self, font_rid: Rid, size: Vector2i, glyph: i64, ) -> Vector2
Returns size of the cache texture containing the glyph.
Note: If there are pending glyphs to render, calling this function might trigger the texture cache update.
pub fn font_get_glyph_contours(
&self,
font: Rid,
size: i64,
index: i64,
) -> Dictionary<Variant, Variant>
pub fn font_get_glyph_contours( &self, font: Rid, size: i64, index: i64, ) -> Dictionary<Variant, Variant>
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 [enum ContourPointTag] values.
contours - PackedInt32Array, containing indices the end points of each contour.
orientation - bool, contour orientation. If true, clockwise contours must be filled.
-
Two successive
ContourPointTag::ONpoints indicate a line segment. -
One
ContourPointTag::OFF_CONICpoint between twoContourPointTag::ONpoints indicates a single conic (quadratic) Bézier arc. -
Two
ContourPointTag::OFF_CUBICpoints between twoContourPointTag::ONpoints indicate a single cubic Bézier arc. -
Two successive
ContourPointTag::OFF_CONICpoints indicate two successive conic (quadratic) Bézier arcs with a virtualContourPointTag::ONpoint at their middle. -
Each contour is closed. The last point of a contour uses the first point of a contour as its next point, and vice versa. The first point can be
ContourPointTag::OFF_CONICpoint.
pub fn font_get_kerning_list(&self, font_rid: Rid, size: i64) -> Array<Vector2i>
pub fn font_get_kerning_list(&self, font_rid: Rid, size: i64) -> Array<Vector2i>
Returns list of the kerning overrides.
pub fn font_clear_kerning_map(&mut self, font_rid: Rid, size: i64)
pub fn font_clear_kerning_map(&mut self, font_rid: Rid, size: i64)
Removes all kerning overrides.
pub fn font_remove_kerning(
&mut self,
font_rid: Rid,
size: i64,
glyph_pair: Vector2i,
)
pub fn font_remove_kerning( &mut self, font_rid: Rid, size: i64, glyph_pair: Vector2i, )
Removes kerning override for the pair of glyphs.
pub fn font_set_kerning(
&mut self,
font_rid: Rid,
size: i64,
glyph_pair: Vector2i,
kerning: Vector2,
)
pub fn font_set_kerning( &mut self, font_rid: Rid, size: i64, glyph_pair: Vector2i, kerning: Vector2, )
Sets kerning for the pair of glyphs.
pub fn font_get_kerning(
&self,
font_rid: Rid,
size: i64,
glyph_pair: Vector2i,
) -> Vector2
pub fn font_get_kerning( &self, font_rid: Rid, size: i64, glyph_pair: Vector2i, ) -> Vector2
Returns kerning for the pair of glyphs.
pub fn font_get_glyph_index(
&self,
font_rid: Rid,
size: i64,
char: i64,
variation_selector: i64,
) -> i64
pub fn font_get_glyph_index( &self, font_rid: Rid, size: i64, char: i64, variation_selector: i64, ) -> i64
Returns the glyph index of a char, optionally modified by the variation_selector. See font_get_char_from_glyph_index.
pub fn font_get_char_from_glyph_index(
&self,
font_rid: Rid,
size: i64,
glyph_index: i64,
) -> i64
pub fn font_get_char_from_glyph_index( &self, font_rid: Rid, size: i64, glyph_index: i64, ) -> i64
Returns character code associated with glyph_index, or 0 if glyph_index is invalid. See font_get_glyph_index.
pub fn font_has_char(&self, font_rid: Rid, char: i64) -> bool
pub fn font_has_char(&self, font_rid: Rid, char: i64) -> bool
Returns true if a Unicode char is available in the font.
pub fn font_get_supported_chars(&self, font_rid: Rid) -> GString
pub fn font_get_supported_chars(&self, font_rid: Rid) -> GString
Returns a string containing all the characters available in the font.
pub fn font_get_supported_glyphs(&self, font_rid: Rid) -> PackedArray<i32>
pub fn font_get_supported_glyphs(&self, font_rid: Rid) -> PackedArray<i32>
Returns an array containing all glyph indices in the font.
pub fn font_render_range(
&mut self,
font_rid: Rid,
size: Vector2i,
start: i64,
end: i64,
)
pub fn font_render_range( &mut self, font_rid: Rid, size: Vector2i, start: i64, end: i64, )
Renders the range of characters to the font cache texture.
pub fn font_render_glyph(&mut self, font_rid: Rid, size: Vector2i, index: i64)
pub fn font_render_glyph(&mut self, font_rid: Rid, size: Vector2i, index: i64)
Renders specified glyph to the font cache texture.
pub fn font_draw_glyph(
&self,
font_rid: Rid,
canvas: Rid,
size: i64,
pos: Vector2,
index: i64,
)
pub fn font_draw_glyph( &self, font_rid: Rid, canvas: Rid, size: i64, pos: Vector2, index: i64, )
To set the default parameters, use font_draw_glyph_ex and its builder methods. See the book for detailed usage instructions.
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.
pub fn font_draw_glyph_ex<'ex>(
&'ex self,
font_rid: Rid,
canvas: Rid,
size: i64,
pos: Vector2,
index: i64,
) -> ExFontDrawGlyph<'ex>
pub fn font_draw_glyph_ex<'ex>( &'ex self, font_rid: Rid, canvas: Rid, size: i64, pos: Vector2, index: i64, ) -> ExFontDrawGlyph<'ex>
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.
pub fn font_draw_glyph_outline(
&self,
font_rid: Rid,
canvas: Rid,
size: i64,
outline_size: i64,
pos: Vector2,
index: i64,
)
pub fn font_draw_glyph_outline( &self, font_rid: Rid, canvas: Rid, size: i64, outline_size: i64, pos: Vector2, index: i64, )
To set the default parameters, use font_draw_glyph_outline_ex and its builder methods. See the book for detailed usage instructions.
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.
pub fn font_draw_glyph_outline_ex<'ex>(
&'ex self,
font_rid: Rid,
canvas: Rid,
size: i64,
outline_size: i64,
pos: Vector2,
index: i64,
) -> ExFontDrawGlyphOutline<'ex>
pub fn font_draw_glyph_outline_ex<'ex>( &'ex self, font_rid: Rid, canvas: Rid, size: i64, outline_size: i64, pos: Vector2, index: i64, ) -> ExFontDrawGlyphOutline<'ex>
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.
pub fn font_is_language_supported(
&self,
font_rid: Rid,
language: impl AsArg<GString>,
) -> bool
pub fn font_is_language_supported( &self, font_rid: Rid, language: impl AsArg<GString>, ) -> bool
Returns true if the font supports the given language (as a ISO 639 code).
pub fn font_set_language_support_override(
&mut self,
font_rid: Rid,
language: impl AsArg<GString>,
supported: bool,
)
pub fn font_set_language_support_override( &mut self, font_rid: Rid, language: impl AsArg<GString>, supported: bool, )
Adds override for font_is_language_supported.
pub fn font_get_language_support_override(
&mut self,
font_rid: Rid,
language: impl AsArg<GString>,
) -> bool
pub fn font_get_language_support_override( &mut self, font_rid: Rid, language: impl AsArg<GString>, ) -> bool
Returns true if support override is enabled for the language.
pub fn font_remove_language_support_override(
&mut self,
font_rid: Rid,
language: impl AsArg<GString>,
)
pub fn font_remove_language_support_override( &mut self, font_rid: Rid, language: impl AsArg<GString>, )
Remove language support override.
pub fn font_get_language_support_overrides(
&mut self,
font_rid: Rid,
) -> PackedArray<GString>
pub fn font_get_language_support_overrides( &mut self, font_rid: Rid, ) -> PackedArray<GString>
Returns list of language support overrides.
pub fn font_is_script_supported(
&self,
font_rid: Rid,
script: impl AsArg<GString>,
) -> bool
pub fn font_is_script_supported( &self, font_rid: Rid, script: impl AsArg<GString>, ) -> bool
Returns true if the font supports the given script (as a ISO 15924 code).
pub fn font_set_script_support_override(
&mut self,
font_rid: Rid,
script: impl AsArg<GString>,
supported: bool,
)
pub fn font_set_script_support_override( &mut self, font_rid: Rid, script: impl AsArg<GString>, supported: bool, )
Adds override for font_is_script_supported.
pub fn font_get_script_support_override(
&mut self,
font_rid: Rid,
script: impl AsArg<GString>,
) -> bool
pub fn font_get_script_support_override( &mut self, font_rid: Rid, script: impl AsArg<GString>, ) -> bool
Returns true if support override is enabled for the script.
pub fn font_remove_script_support_override(
&mut self,
font_rid: Rid,
script: impl AsArg<GString>,
)
pub fn font_remove_script_support_override( &mut self, font_rid: Rid, script: impl AsArg<GString>, )
Removes script support override.
pub fn font_get_script_support_overrides(
&mut self,
font_rid: Rid,
) -> PackedArray<GString>
pub fn font_get_script_support_overrides( &mut self, font_rid: Rid, ) -> PackedArray<GString>
Returns list of script support overrides.
pub fn font_set_opentype_feature_overrides(
&mut self,
font_rid: Rid,
overrides: &AnyDictionary,
)
pub fn font_set_opentype_feature_overrides( &mut self, font_rid: Rid, overrides: &AnyDictionary, )
Sets font OpenType feature set override.
pub fn font_get_opentype_feature_overrides(
&self,
font_rid: Rid,
) -> Dictionary<Variant, Variant>
pub fn font_get_opentype_feature_overrides( &self, font_rid: Rid, ) -> Dictionary<Variant, Variant>
Returns font OpenType feature set override.
pub fn font_supported_feature_list(
&self,
font_rid: Rid,
) -> Dictionary<Variant, Variant>
pub fn font_supported_feature_list( &self, font_rid: Rid, ) -> Dictionary<Variant, Variant>
Returns the dictionary of the supported OpenType features.
pub fn font_supported_variation_list(
&self,
font_rid: Rid,
) -> Dictionary<Variant, Variant>
pub fn font_supported_variation_list( &self, font_rid: Rid, ) -> Dictionary<Variant, Variant>
Returns the dictionary of the supported OpenType variation coordinates.
pub fn font_get_global_oversampling(&self) -> f64
pub fn font_get_global_oversampling(&self) -> f64
This method does nothing and always returns 1.0.
pub fn font_set_global_oversampling(&mut self, oversampling: f64)
pub fn font_set_global_oversampling(&mut self, oversampling: f64)
This method does nothing.
pub fn get_hex_code_box_size(&self, size: i64, index: i64) -> Vector2
pub fn get_hex_code_box_size(&self, size: i64, index: i64) -> Vector2
Returns size of the replacement character (box with character hexadecimal code that is drawn in place of invalid characters).
pub fn draw_hex_code_box(
&self,
canvas: Rid,
size: i64,
pos: Vector2,
index: i64,
color: Color,
)
pub fn draw_hex_code_box( &self, canvas: Rid, size: i64, pos: Vector2, index: i64, color: Color, )
Draws box displaying character hexadecimal code. Used for replacing missing characters.
pub fn create_shaped_text(&mut self) -> Rid
pub fn create_shaped_text(&mut self) -> Rid
To set the default parameters, use create_shaped_text_ex and its builder methods. See the book for detailed usage instructions.
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).
pub fn create_shaped_text_ex<'ex>(&'ex mut self) -> ExCreateShapedText<'ex>
pub fn create_shaped_text_ex<'ex>(&'ex mut self) -> ExCreateShapedText<'ex>
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).
pub fn shaped_text_clear(&mut self, rid: Rid)
pub fn shaped_text_clear(&mut self, rid: Rid)
Clears text buffer (removes text and inline objects).
pub fn shaped_text_duplicate(&mut self, rid: Rid) -> Rid
pub fn shaped_text_duplicate(&mut self, rid: Rid) -> Rid
Duplicates shaped text buffer.
pub fn shaped_text_set_direction(&mut self, shaped: Rid)
pub fn shaped_text_set_direction(&mut self, shaped: Rid)
To set the default parameters, use shaped_text_set_direction_ex and its builder methods. See the book for detailed usage instructions.
Sets desired text direction. If set to Direction::AUTO, direction will be detected based on the buffer contents and current locale.
Note: Direction is ignored if server does not support Feature::BIDI_LAYOUT feature (supported by TextServerAdvanced).
pub fn shaped_text_set_direction_ex<'ex>(
&'ex mut self,
shaped: Rid,
) -> ExShapedTextSetDirection<'ex>
pub fn shaped_text_set_direction_ex<'ex>( &'ex mut self, shaped: Rid, ) -> ExShapedTextSetDirection<'ex>
Sets desired text direction. If set to Direction::AUTO, direction will be detected based on the buffer contents and current locale.
Note: Direction is ignored if server does not support Feature::BIDI_LAYOUT feature (supported by TextServerAdvanced).
pub fn shaped_text_get_direction(&self, shaped: Rid) -> Direction
pub fn shaped_text_get_direction(&self, shaped: Rid) -> Direction
Returns direction of the text.
pub fn shaped_text_get_inferred_direction(&self, shaped: Rid) -> Direction
pub fn shaped_text_get_inferred_direction(&self, shaped: Rid) -> Direction
Returns direction of the text, inferred by the BiDi algorithm.
pub fn shaped_text_set_bidi_override(
&mut self,
shaped: Rid,
override_: &AnyArray,
)
pub fn shaped_text_set_bidi_override( &mut self, shaped: Rid, override_: &AnyArray, )
Overrides BiDi for the structured text.
Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately.
pub fn shaped_text_set_custom_punctuation(
&mut self,
shaped: Rid,
punct: impl AsArg<GString>,
)
pub fn shaped_text_set_custom_punctuation( &mut self, shaped: Rid, punct: impl AsArg<GString>, )
Sets custom punctuation character list, used for word breaking. If set to empty string, server defaults are used.
pub fn shaped_text_get_custom_punctuation(&self, shaped: Rid) -> GString
pub fn shaped_text_get_custom_punctuation(&self, shaped: Rid) -> GString
Returns custom punctuation character list, used for word breaking. If set to empty string, server defaults are used.
pub fn shaped_text_set_custom_ellipsis(&mut self, shaped: Rid, char: i64)
pub fn shaped_text_set_custom_ellipsis(&mut self, shaped: Rid, char: i64)
Sets ellipsis character used for text clipping.
pub fn shaped_text_get_custom_ellipsis(&self, shaped: Rid) -> i64
pub fn shaped_text_get_custom_ellipsis(&self, shaped: Rid) -> i64
Returns ellipsis character used for text clipping.
pub fn shaped_text_set_orientation(&mut self, shaped: Rid)
pub fn shaped_text_set_orientation(&mut self, shaped: Rid)
To set the default parameters, use shaped_text_set_orientation_ex and its builder methods. See the book for detailed usage instructions.
Sets desired text orientation.
Note: Orientation is ignored if server does not support Feature::VERTICAL_LAYOUT feature (supported by TextServerAdvanced).
pub fn shaped_text_set_orientation_ex<'ex>(
&'ex mut self,
shaped: Rid,
) -> ExShapedTextSetOrientation<'ex>
pub fn shaped_text_set_orientation_ex<'ex>( &'ex mut self, shaped: Rid, ) -> ExShapedTextSetOrientation<'ex>
Sets desired text orientation.
Note: Orientation is ignored if server does not support Feature::VERTICAL_LAYOUT feature (supported by TextServerAdvanced).
pub fn shaped_text_get_orientation(&self, shaped: Rid) -> Orientation
pub fn shaped_text_get_orientation(&self, shaped: Rid) -> Orientation
Returns text orientation.
pub fn shaped_text_set_preserve_invalid(&mut self, shaped: Rid, enabled: bool)
pub fn shaped_text_set_preserve_invalid(&mut self, shaped: Rid, enabled: bool)
If set to true text buffer will display invalid characters as hexadecimal codes, otherwise nothing is displayed.
pub fn shaped_text_get_preserve_invalid(&self, shaped: Rid) -> bool
pub fn shaped_text_get_preserve_invalid(&self, shaped: Rid) -> bool
Returns true if text buffer is configured to display hexadecimal codes in place of invalid characters.
Note: If set to false, nothing is displayed in place of invalid characters.
pub fn shaped_text_set_preserve_control(&mut self, shaped: Rid, enabled: bool)
pub fn shaped_text_set_preserve_control(&mut self, shaped: Rid, enabled: bool)
If set to true text buffer will display control characters.
pub fn shaped_text_get_preserve_control(&self, shaped: Rid) -> bool
pub fn shaped_text_get_preserve_control(&self, shaped: Rid) -> bool
Returns true if text buffer is configured to display control characters.
pub fn shaped_text_set_spacing(
&mut self,
shaped: Rid,
spacing: SpacingType,
value: i64,
)
pub fn shaped_text_set_spacing( &mut self, shaped: Rid, spacing: SpacingType, value: i64, )
Sets extra spacing added between glyphs or lines in pixels.
pub fn shaped_text_get_spacing(&self, shaped: Rid, spacing: SpacingType) -> i64
pub fn shaped_text_get_spacing(&self, shaped: Rid, spacing: SpacingType) -> i64
Returns extra spacing added between glyphs or lines in pixels.
pub fn shaped_text_add_string(
&mut self,
shaped: Rid,
text: impl AsArg<GString>,
fonts: &Array<Rid>,
size: i64,
) -> bool
pub fn shaped_text_add_string( &mut self, shaped: Rid, text: impl AsArg<GString>, fonts: &Array<Rid>, size: i64, ) -> bool
To set the default parameters, use shaped_text_add_string_ex and its builder methods. See the book for detailed usage instructions.
Adds text span and font to draw it to the text buffer.
pub fn shaped_text_add_string_ex<'ex>(
&'ex mut self,
shaped: Rid,
text: impl AsArg<GString> + 'ex,
fonts: &'ex Array<Rid>,
size: i64,
) -> ExShapedTextAddString<'ex>
pub fn shaped_text_add_string_ex<'ex>( &'ex mut self, shaped: Rid, text: impl AsArg<GString> + 'ex, fonts: &'ex Array<Rid>, size: i64, ) -> ExShapedTextAddString<'ex>
Adds text span and font to draw it to the text buffer.
pub fn shaped_text_add_object(
&mut self,
shaped: Rid,
key: &Variant,
size: Vector2,
) -> bool
pub fn shaped_text_add_object( &mut self, shaped: Rid, key: &Variant, size: Vector2, ) -> bool
To set the default parameters, use shaped_text_add_object_ex and its builder methods. See the book for detailed usage instructions.
Adds inline object to the text buffer, key must be unique. In the text, object is represented as length object replacement characters.
pub fn shaped_text_add_object_ex<'ex>(
&'ex mut self,
shaped: Rid,
key: &'ex Variant,
size: Vector2,
) -> ExShapedTextAddObject<'ex>
pub fn shaped_text_add_object_ex<'ex>( &'ex mut self, shaped: Rid, key: &'ex Variant, size: Vector2, ) -> ExShapedTextAddObject<'ex>
Adds inline object to the text buffer, key must be unique. In the text, object is represented as length object replacement characters.
pub fn shaped_text_resize_object(
&mut self,
shaped: Rid,
key: &Variant,
size: Vector2,
) -> bool
pub fn shaped_text_resize_object( &mut self, shaped: Rid, key: &Variant, size: Vector2, ) -> bool
To set the default parameters, use shaped_text_resize_object_ex and its builder methods. See the book for detailed usage instructions.
Sets new size and alignment of embedded object.
pub fn shaped_text_resize_object_ex<'ex>(
&'ex mut self,
shaped: Rid,
key: &'ex Variant,
size: Vector2,
) -> ExShapedTextResizeObject<'ex>
pub fn shaped_text_resize_object_ex<'ex>( &'ex mut self, shaped: Rid, key: &'ex Variant, size: Vector2, ) -> ExShapedTextResizeObject<'ex>
Sets new size and alignment of embedded object.
pub fn shaped_text_has_object(&self, shaped: Rid, key: &Variant) -> bool
pub fn shaped_text_has_object(&self, shaped: Rid, key: &Variant) -> bool
Returns true if an object with key is embedded in this shaped text buffer.
pub fn shaped_get_text(&self, shaped: Rid) -> GString
pub fn shaped_get_text(&self, shaped: Rid) -> GString
Returns the text buffer source text, including object replacement characters.
pub fn shaped_get_span_count(&self, shaped: Rid) -> i64
pub fn shaped_get_span_count(&self, shaped: Rid) -> i64
Returns number of text spans added using shaped_text_add_string or shaped_text_add_object.
pub fn shaped_get_span_meta(&self, shaped: Rid, index: i64) -> Variant
pub fn shaped_get_span_meta(&self, shaped: Rid, index: i64) -> Variant
Returns text span metadata.
pub fn shaped_get_span_embedded_object(
&self,
shaped: Rid,
index: i64,
) -> Variant
pub fn shaped_get_span_embedded_object( &self, shaped: Rid, index: i64, ) -> Variant
Returns text embedded object key.
pub fn shaped_get_span_text(&self, shaped: Rid, index: i64) -> GString
pub fn shaped_get_span_text(&self, shaped: Rid, index: i64) -> GString
Returns the text span source text.
pub fn shaped_get_span_object(&self, shaped: Rid, index: i64) -> Variant
pub fn shaped_get_span_object(&self, shaped: Rid, index: i64) -> Variant
Returns the text span embedded object key.
pub fn shaped_set_span_update_font(
&mut self,
shaped: Rid,
index: i64,
fonts: &Array<Rid>,
size: i64,
)
pub fn shaped_set_span_update_font( &mut self, shaped: Rid, index: i64, fonts: &Array<Rid>, size: i64, )
To set the default parameters, use shaped_set_span_update_font_ex and its builder methods. See the book for detailed usage instructions.
Changes text span font, font size, and OpenType features, without changing the text.
pub fn shaped_set_span_update_font_ex<'ex>(
&'ex mut self,
shaped: Rid,
index: i64,
fonts: &'ex Array<Rid>,
size: i64,
) -> ExShapedSetSpanUpdateFont<'ex>
pub fn shaped_set_span_update_font_ex<'ex>( &'ex mut self, shaped: Rid, index: i64, fonts: &'ex Array<Rid>, size: i64, ) -> ExShapedSetSpanUpdateFont<'ex>
Changes text span font, font size, and OpenType features, without changing the text.
pub fn shaped_get_run_count(&self, shaped: Rid) -> i64
pub fn shaped_get_run_count(&self, shaped: Rid) -> i64
Returns the number of uniform text runs in the buffer.
pub fn shaped_get_run_text(&self, shaped: Rid, index: i64) -> GString
pub fn shaped_get_run_text(&self, shaped: Rid, index: i64) -> GString
Returns the source text of the index text run (in visual order).
pub fn shaped_get_run_range(&self, shaped: Rid, index: i64) -> Vector2i
pub fn shaped_get_run_range(&self, shaped: Rid, index: i64) -> Vector2i
Returns the source text range of the index text run (in visual order).
pub fn shaped_get_run_font_rid(&self, shaped: Rid, index: i64) -> Rid
pub fn shaped_get_run_font_rid(&self, shaped: Rid, index: i64) -> Rid
Returns the font RID of the index text run (in visual order).
pub fn shaped_get_run_font_size(&self, shaped: Rid, index: i64) -> i32
pub fn shaped_get_run_font_size(&self, shaped: Rid, index: i64) -> i32
Returns the font size of the index text run (in visual order).
pub fn shaped_get_run_language(&self, shaped: Rid, index: i64) -> GString
pub fn shaped_get_run_language(&self, shaped: Rid, index: i64) -> GString
Returns the language of the index text run (in visual order).
pub fn shaped_get_run_direction(&self, shaped: Rid, index: i64) -> Direction
pub fn shaped_get_run_direction(&self, shaped: Rid, index: i64) -> Direction
Returns the direction of the index text run (in visual order).
pub fn shaped_get_run_object(&self, shaped: Rid, index: i64) -> Variant
pub fn shaped_get_run_object(&self, shaped: Rid, index: i64) -> Variant
Returns the embedded object of the index text run (in visual order).
pub fn shaped_text_substr(&self, shaped: Rid, start: i64, length: i64) -> Rid
pub fn shaped_text_substr(&self, shaped: Rid, start: i64, length: i64) -> Rid
Returns text buffer for the substring of the text in the shaped text buffer (including inline objects).
pub fn shaped_text_get_parent(&self, shaped: Rid) -> Rid
pub fn shaped_text_get_parent(&self, shaped: Rid) -> Rid
Returns the parent buffer from which the substring originates.
pub fn shaped_text_fit_to_width(&mut self, shaped: Rid, width: f64) -> f64
pub fn shaped_text_fit_to_width(&mut self, shaped: Rid, width: f64) -> f64
To set the default parameters, use shaped_text_fit_to_width_ex and its builder methods. See the book for detailed usage instructions.
Adjusts text width to fit to specified width, returns new text width.
pub fn shaped_text_fit_to_width_ex<'ex>(
&'ex mut self,
shaped: Rid,
width: f64,
) -> ExShapedTextFitToWidth<'ex>
pub fn shaped_text_fit_to_width_ex<'ex>( &'ex mut self, shaped: Rid, width: f64, ) -> ExShapedTextFitToWidth<'ex>
Adjusts text width to fit to specified width, returns new text width.
pub fn shaped_text_tab_align(
&mut self,
shaped: Rid,
tab_stops: &PackedArray<f32>,
) -> f64
pub fn shaped_text_tab_align( &mut self, shaped: Rid, tab_stops: &PackedArray<f32>, ) -> f64
Aligns shaped text to the given tab-stops.
pub fn shaped_text_shape(&mut self, shaped: Rid) -> bool
pub fn shaped_text_shape(&mut self, shaped: Rid) -> bool
Shapes buffer if it’s not shaped. Returns true if the string is shaped successfully.
Note: It is not necessary to call this function manually, buffer will be shaped automatically as soon as any of its output data is requested.
pub fn shaped_text_is_ready(&self, shaped: Rid) -> bool
pub fn shaped_text_is_ready(&self, shaped: Rid) -> bool
Returns true if buffer is successfully shaped.
pub fn shaped_text_has_visible_chars(&self, shaped: Rid) -> bool
pub fn shaped_text_has_visible_chars(&self, shaped: Rid) -> bool
Returns true if text buffer contains any visible characters.
pub fn shaped_text_get_glyphs(
&self,
shaped: Rid,
) -> Array<Dictionary<Variant, Variant>>
pub fn shaped_text_get_glyphs( &self, shaped: Rid, ) -> Array<Dictionary<Variant, Variant>>
Returns an array of glyphs in the visual order.
pub fn shaped_text_sort_logical(
&mut self,
shaped: Rid,
) -> Array<Dictionary<Variant, Variant>>
pub fn shaped_text_sort_logical( &mut self, shaped: Rid, ) -> Array<Dictionary<Variant, Variant>>
Returns text glyphs in the logical order.
pub fn shaped_text_get_glyph_count(&self, shaped: Rid) -> i64
pub fn shaped_text_get_glyph_count(&self, shaped: Rid) -> i64
Returns number of glyphs in the buffer.
pub fn shaped_text_get_range(&self, shaped: Rid) -> Vector2i
pub fn shaped_text_get_range(&self, shaped: Rid) -> Vector2i
Returns substring buffer character range in the parent buffer.
pub fn shaped_text_get_line_breaks_adv(
&self,
shaped: Rid,
width: &PackedArray<f32>,
) -> PackedArray<i32>
pub fn shaped_text_get_line_breaks_adv( &self, shaped: Rid, width: &PackedArray<f32>, ) -> PackedArray<i32>
To set the default parameters, use shaped_text_get_line_breaks_adv_ex and its builder methods. See the book for detailed usage instructions.
Breaks text to the lines and columns. Returns character ranges for each segment.
pub fn shaped_text_get_line_breaks_adv_ex<'ex>(
&'ex self,
shaped: Rid,
width: &'ex PackedArray<f32>,
) -> ExShapedTextGetLineBreaksAdv<'ex>
pub fn shaped_text_get_line_breaks_adv_ex<'ex>( &'ex self, shaped: Rid, width: &'ex PackedArray<f32>, ) -> ExShapedTextGetLineBreaksAdv<'ex>
Breaks text to the lines and columns. Returns character ranges for each segment.
pub fn shaped_text_get_line_breaks(
&self,
shaped: Rid,
width: f64,
) -> PackedArray<i32>
pub fn shaped_text_get_line_breaks( &self, shaped: Rid, width: f64, ) -> PackedArray<i32>
To set the default parameters, use shaped_text_get_line_breaks_ex and its builder methods. See the book for detailed usage instructions.
Breaks text to the lines and returns character ranges for each line.
pub fn shaped_text_get_line_breaks_ex<'ex>(
&'ex self,
shaped: Rid,
width: f64,
) -> ExShapedTextGetLineBreaks<'ex>
pub fn shaped_text_get_line_breaks_ex<'ex>( &'ex self, shaped: Rid, width: f64, ) -> ExShapedTextGetLineBreaks<'ex>
Breaks text to the lines and returns character ranges for each line.
pub fn shaped_text_get_word_breaks(&self, shaped: Rid) -> PackedArray<i32>
pub fn shaped_text_get_word_breaks(&self, shaped: Rid) -> PackedArray<i32>
To set the default parameters, use shaped_text_get_word_breaks_ex and its builder methods. See the book for detailed usage instructions.
Breaks text into words and returns array of character ranges. Use grapheme_flags to set what characters are used for breaking.
pub fn shaped_text_get_word_breaks_ex<'ex>(
&'ex self,
shaped: Rid,
) -> ExShapedTextGetWordBreaks<'ex>
pub fn shaped_text_get_word_breaks_ex<'ex>( &'ex self, shaped: Rid, ) -> ExShapedTextGetWordBreaks<'ex>
Breaks text into words and returns array of character ranges. Use grapheme_flags to set what characters are used for breaking.
pub fn shaped_text_get_trim_pos(&self, shaped: Rid) -> i64
pub fn shaped_text_get_trim_pos(&self, shaped: Rid) -> i64
Returns the position of the overrun trim.
pub fn shaped_text_get_ellipsis_pos(&self, shaped: Rid) -> i64
pub fn shaped_text_get_ellipsis_pos(&self, shaped: Rid) -> i64
Returns position of the ellipsis.
pub fn shaped_text_get_ellipsis_glyphs(
&self,
shaped: Rid,
) -> Array<Dictionary<Variant, Variant>>
pub fn shaped_text_get_ellipsis_glyphs( &self, shaped: Rid, ) -> Array<Dictionary<Variant, Variant>>
Returns array of the glyphs in the ellipsis.
pub fn shaped_text_get_ellipsis_glyph_count(&self, shaped: Rid) -> i64
pub fn shaped_text_get_ellipsis_glyph_count(&self, shaped: Rid) -> i64
Returns number of glyphs in the ellipsis.
pub fn shaped_text_overrun_trim_to_width(&mut self, shaped: Rid)
pub fn shaped_text_overrun_trim_to_width(&mut self, shaped: Rid)
To set the default parameters, use shaped_text_overrun_trim_to_width_ex and its builder methods. See the book for detailed usage instructions.
Trims text if it exceeds the given width.
pub fn shaped_text_overrun_trim_to_width_ex<'ex>(
&'ex mut self,
shaped: Rid,
) -> ExShapedTextOverrunTrimToWidth<'ex>
pub fn shaped_text_overrun_trim_to_width_ex<'ex>( &'ex mut self, shaped: Rid, ) -> ExShapedTextOverrunTrimToWidth<'ex>
Trims text if it exceeds the given width.
pub fn shaped_text_get_objects(&self, shaped: Rid) -> Array<Variant>
pub fn shaped_text_get_objects(&self, shaped: Rid) -> Array<Variant>
Returns array of inline objects.
pub fn shaped_text_get_object_rect(&self, shaped: Rid, key: &Variant) -> Rect2
pub fn shaped_text_get_object_rect(&self, shaped: Rid, key: &Variant) -> Rect2
Returns bounding rectangle of the inline object.
pub fn shaped_text_get_object_range(
&self,
shaped: Rid,
key: &Variant,
) -> Vector2i
pub fn shaped_text_get_object_range( &self, shaped: Rid, key: &Variant, ) -> Vector2i
Returns the character range of the inline object.
pub fn shaped_text_get_object_glyph(&self, shaped: Rid, key: &Variant) -> i64
pub fn shaped_text_get_object_glyph(&self, shaped: Rid, key: &Variant) -> i64
Returns the glyph index of the inline object.
pub fn shaped_text_get_size(&self, shaped: Rid) -> Vector2
pub fn shaped_text_get_size(&self, shaped: Rid) -> Vector2
Returns size of the text.
pub fn shaped_text_get_ascent(&self, shaped: Rid) -> f64
pub fn shaped_text_get_ascent(&self, shaped: Rid) -> f64
Returns the text ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical).
Note: Overall ascent can be higher than font ascent, if some glyphs are displaced from the baseline.
pub fn shaped_text_get_descent(&self, shaped: Rid) -> f64
pub fn shaped_text_get_descent(&self, shaped: Rid) -> f64
Returns the text descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical).
Note: Overall descent can be higher than font descent, if some glyphs are displaced from the baseline.
pub fn shaped_text_get_width(&self, shaped: Rid) -> f64
pub fn shaped_text_get_width(&self, shaped: Rid) -> f64
Returns width (for horizontal layout) or height (for vertical) of the text.
pub fn shaped_text_get_underline_position(&self, shaped: Rid) -> f64
pub fn shaped_text_get_underline_position(&self, shaped: Rid) -> f64
Returns pixel offset of the underline below the baseline.
pub fn shaped_text_get_underline_thickness(&self, shaped: Rid) -> f64
pub fn shaped_text_get_underline_thickness(&self, shaped: Rid) -> f64
Returns thickness of the underline.
pub fn shaped_text_get_carets(
&self,
shaped: Rid,
position: i64,
) -> Dictionary<Variant, Variant>
pub fn shaped_text_get_carets( &self, shaped: Rid, position: i64, ) -> Dictionary<Variant, Variant>
Returns shapes of the carets corresponding to the character offset position in the text. Returned caret shape is 1 pixel wide rectangle.
pub fn shaped_text_get_selection(
&self,
shaped: Rid,
start: i64,
end: i64,
) -> PackedArray<Vector2>
pub fn shaped_text_get_selection( &self, shaped: Rid, start: i64, end: i64, ) -> PackedArray<Vector2>
Returns selection rectangles for the specified character range.
pub fn shaped_text_hit_test_grapheme(&self, shaped: Rid, coords: f64) -> i64
pub fn shaped_text_hit_test_grapheme(&self, shaped: Rid, coords: f64) -> i64
Returns grapheme index at the specified pixel offset at the baseline, or -1 if none is found.
pub fn shaped_text_hit_test_position(&self, shaped: Rid, coords: f64) -> i64
pub fn shaped_text_hit_test_position(&self, shaped: Rid, coords: f64) -> i64
Returns caret character offset at the specified pixel offset at the baseline. This function always returns a valid position.
pub fn shaped_text_get_grapheme_bounds(&self, shaped: Rid, pos: i64) -> Vector2
pub fn shaped_text_get_grapheme_bounds(&self, shaped: Rid, pos: i64) -> Vector2
Returns composite character’s bounds as offsets from the start of the line.
pub fn shaped_text_next_grapheme_pos(&self, shaped: Rid, pos: i64) -> i64
pub fn shaped_text_next_grapheme_pos(&self, shaped: Rid, pos: i64) -> i64
Returns grapheme end position closest to the pos.
pub fn shaped_text_prev_grapheme_pos(&self, shaped: Rid, pos: i64) -> i64
pub fn shaped_text_prev_grapheme_pos(&self, shaped: Rid, pos: i64) -> i64
Returns grapheme start position closest to the pos.
pub fn shaped_text_get_character_breaks(&self, shaped: Rid) -> PackedArray<i32>
pub fn shaped_text_get_character_breaks(&self, shaped: Rid) -> PackedArray<i32>
Returns array of the composite character boundaries.
pub fn shaped_text_next_character_pos(&self, shaped: Rid, pos: i64) -> i64
pub fn shaped_text_next_character_pos(&self, shaped: Rid, pos: i64) -> i64
Returns composite character end position closest to the pos.
pub fn shaped_text_prev_character_pos(&self, shaped: Rid, pos: i64) -> i64
pub fn shaped_text_prev_character_pos(&self, shaped: Rid, pos: i64) -> i64
Returns composite character start position closest to the pos.
pub fn shaped_text_closest_character_pos(&self, shaped: Rid, pos: i64) -> i64
pub fn shaped_text_closest_character_pos(&self, shaped: Rid, pos: i64) -> i64
Returns composite character position closest to the pos.
pub fn shaped_text_draw(&self, shaped: Rid, canvas: Rid, pos: Vector2)
pub fn shaped_text_draw(&self, shaped: Rid, canvas: Rid, pos: Vector2)
To set the default parameters, use shaped_text_draw_ex and its builder methods. See the book for detailed usage instructions.
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.
pub fn shaped_text_draw_ex<'ex>(
&'ex self,
shaped: Rid,
canvas: Rid,
pos: Vector2,
) -> ExShapedTextDraw<'ex>
pub fn shaped_text_draw_ex<'ex>( &'ex self, shaped: Rid, canvas: Rid, pos: Vector2, ) -> ExShapedTextDraw<'ex>
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.
pub fn shaped_text_draw_outline(&self, shaped: Rid, canvas: Rid, pos: Vector2)
pub fn shaped_text_draw_outline(&self, shaped: Rid, canvas: Rid, pos: Vector2)
To set the default parameters, use shaped_text_draw_outline_ex and its builder methods. See the book for detailed usage instructions.
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.
pub fn shaped_text_draw_outline_ex<'ex>(
&'ex self,
shaped: Rid,
canvas: Rid,
pos: Vector2,
) -> ExShapedTextDrawOutline<'ex>
pub fn shaped_text_draw_outline_ex<'ex>( &'ex self, shaped: Rid, canvas: Rid, pos: Vector2, ) -> ExShapedTextDrawOutline<'ex>
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.
pub fn shaped_text_get_dominant_direction_in_range(
&self,
shaped: Rid,
start: i64,
end: i64,
) -> Direction
pub fn shaped_text_get_dominant_direction_in_range( &self, shaped: Rid, start: i64, end: i64, ) -> Direction
Returns dominant direction of in the range of text.
pub fn format_number(&self, number: impl AsArg<GString>) -> GString
pub fn format_number(&self, number: impl AsArg<GString>) -> GString
To set the default parameters, use format_number_ex and its builder methods. See the book for detailed usage instructions.
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.
pub fn format_number_ex<'ex>(
&'ex self,
number: impl AsArg<GString> + 'ex,
) -> ExFormatNumber<'ex>
pub fn format_number_ex<'ex>( &'ex self, number: impl AsArg<GString> + 'ex, ) -> ExFormatNumber<'ex>
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.
pub fn parse_number(&self, number: impl AsArg<GString>) -> GString
pub fn parse_number(&self, number: impl AsArg<GString>) -> GString
To set the default parameters, use parse_number_ex and its builder methods. See the book for detailed usage instructions.
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.
pub fn parse_number_ex<'ex>(
&'ex self,
number: impl AsArg<GString> + 'ex,
) -> ExParseNumber<'ex>
pub fn parse_number_ex<'ex>( &'ex self, number: impl AsArg<GString> + 'ex, ) -> ExParseNumber<'ex>
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.
pub fn percent_sign(&self) -> GString
pub fn percent_sign(&self) -> GString
To set the default parameters, use percent_sign_ex and its builder methods. See the book for detailed usage instructions.
Returns the percent sign used in the given language.
If language is an empty string, the active locale will be used.
pub fn percent_sign_ex<'ex>(&'ex self) -> ExPercentSign<'ex>
pub fn percent_sign_ex<'ex>(&'ex self) -> ExPercentSign<'ex>
Returns the percent sign used in the given language.
If language is an empty string, the active locale will be used.
pub fn string_get_word_breaks(
&self,
string: impl AsArg<GString>,
) -> PackedArray<i32>
pub fn string_get_word_breaks( &self, string: impl AsArg<GString>, ) -> PackedArray<i32>
To set the default parameters, use string_get_word_breaks_ex and its builder methods. See the book for detailed usage instructions.
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]pub fn string_get_word_breaks_ex<'ex>(
&'ex self,
string: impl AsArg<GString> + 'ex,
) -> ExStringGetWordBreaks<'ex>
pub fn string_get_word_breaks_ex<'ex>( &'ex self, string: impl AsArg<GString> + 'ex, ) -> ExStringGetWordBreaks<'ex>
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]pub fn string_get_character_breaks(
&self,
string: impl AsArg<GString>,
) -> PackedArray<i32>
pub fn string_get_character_breaks( &self, string: impl AsArg<GString>, ) -> PackedArray<i32>
To set the default parameters, use string_get_character_breaks_ex and its builder methods. See the book for detailed usage instructions.
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]pub fn string_get_character_breaks_ex<'ex>(
&'ex self,
string: impl AsArg<GString> + 'ex,
) -> ExStringGetCharacterBreaks<'ex>
pub fn string_get_character_breaks_ex<'ex>( &'ex self, string: impl AsArg<GString> + 'ex, ) -> ExStringGetCharacterBreaks<'ex>
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]pub fn is_confusable(
&self,
string: impl AsArg<GString>,
dict: &PackedArray<GString>,
) -> i64
pub fn is_confusable( &self, string: impl AsArg<GString>, dict: &PackedArray<GString>, ) -> i64
Returns index of the first string in dict which is visually confusable with the string, or -1 if none is found.
Note: This method doesn’t detect invisible characters, for spoof detection use it in combination with spoof_check.
Note: Always returns -1 if the server does not support the Feature::UNICODE_SECURITY feature.
pub fn spoof_check(&self, string: impl AsArg<GString>) -> bool
pub fn spoof_check(&self, string: impl AsArg<GString>) -> bool
Returns true if string is likely to be an attempt at confusing the reader.
Note: Always returns false if the server does not support the Feature::UNICODE_SECURITY feature.
pub fn strip_diacritics(&self, string: impl AsArg<GString>) -> GString
pub fn strip_diacritics(&self, string: impl AsArg<GString>) -> GString
Strips diacritics from the string.
Note: The result may be longer or shorter than the original.
pub fn is_valid_identifier(&self, string: impl AsArg<GString>) -> bool
pub fn is_valid_identifier(&self, string: impl AsArg<GString>) -> bool
Returns true if string is a valid identifier.
If the text server supports the Feature::UNICODE_IDENTIFIERS feature, a valid identifier must:
-
Conform to normalization form C.
-
Begin with a Unicode character of class XID_Start or
"_". -
May contain Unicode characters of class XID_Continue in the other positions.
-
Use UAX #31 recommended scripts only (mixed scripts are allowed).
If the Feature::UNICODE_IDENTIFIERS feature is not supported, a valid identifier must:
-
Begin with a Unicode character of class XID_Start or
"_". -
May contain Unicode characters of class XID_Continue in the other positions.
pub fn is_valid_letter(&self, unicode: u64) -> bool
pub fn is_valid_letter(&self, unicode: u64) -> bool
Returns true if the given code point is a valid letter, i.e. it belongs to the Unicode category “L”.
pub fn string_to_upper(&self, string: impl AsArg<GString>) -> GString
pub fn string_to_upper(&self, string: impl AsArg<GString>) -> GString
To set the default parameters, use string_to_upper_ex and its builder methods. See the book for detailed usage instructions.
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.
pub fn string_to_upper_ex<'ex>(
&'ex self,
string: impl AsArg<GString> + 'ex,
) -> ExStringToUpper<'ex>
pub fn string_to_upper_ex<'ex>( &'ex self, string: impl AsArg<GString> + 'ex, ) -> ExStringToUpper<'ex>
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.
pub fn string_to_lower(&self, string: impl AsArg<GString>) -> GString
pub fn string_to_lower(&self, string: impl AsArg<GString>) -> GString
To set the default parameters, use string_to_lower_ex and its builder methods. See the book for detailed usage instructions.
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.
pub fn string_to_lower_ex<'ex>(
&'ex self,
string: impl AsArg<GString> + 'ex,
) -> ExStringToLower<'ex>
pub fn string_to_lower_ex<'ex>( &'ex self, string: impl AsArg<GString> + 'ex, ) -> ExStringToLower<'ex>
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.
pub fn string_to_title(&self, string: impl AsArg<GString>) -> GString
pub fn string_to_title(&self, string: impl AsArg<GString>) -> GString
To set the default parameters, use string_to_title_ex and its builder methods. See the book for detailed usage instructions.
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.
pub fn string_to_title_ex<'ex>(
&'ex self,
string: impl AsArg<GString> + 'ex,
) -> ExStringToTitle<'ex>
pub fn string_to_title_ex<'ex>( &'ex self, string: impl AsArg<GString> + 'ex, ) -> ExStringToTitle<'ex>
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.
pub fn parse_structured_text(
&self,
parser_type: StructuredTextParser,
args: &AnyArray,
text: impl AsArg<GString>,
) -> Array<Vector3i>
pub fn parse_structured_text( &self, parser_type: StructuredTextParser, args: &AnyArray, text: impl AsArg<GString>, ) -> Array<Vector3i>
Default implementation of the BiDi algorithm override function.
Methods from Deref<Target = RefCounted>§
pub fn get_reference_count(&self) -> i32
pub fn get_reference_count(&self) -> i32
Returns the current reference count.
Methods from Deref<Target = Object>§
pub fn get_script(&self) -> Option<Gd<Script>>
pub fn set_script(&mut self, script: impl AsArg<Option<Gd<Script>>>)
pub fn connect( &mut self, signal: impl AsArg<StringName>, callable: &Callable, ) -> Error
pub fn connect_flags( &mut self, signal: impl AsArg<StringName>, callable: &Callable, flags: ConnectFlags, ) -> Error
pub fn is_class(&self, class: impl AsArg<GString>) -> bool
pub fn is_class(&self, class: impl AsArg<GString>) -> bool
Returns true if the object inherits from the given class. See also get_class.
var sprite2d = Sprite2D.new()
sprite2d.is_class("Sprite2D") # Returns true
sprite2d.is_class("Node") # Returns true
sprite2d.is_class("Node3D") # Returns falseNote: This method ignores class_name declarations in the object’s script.
pub fn set(&mut self, property: impl AsArg<StringName>, value: &Variant)
pub fn set(&mut self, property: impl AsArg<StringName>, value: &Variant)
Assigns value to the given property. If the property does not exist or the given value’s type doesn’t match, nothing happens.
var node = Node2D.new()
node.set("global_scale", Vector2(8, 2.5))
print(node.global_scale) # Prints (8.0, 2.5)Note: In C#, property must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the PropertyName class to avoid allocating a new StringName on each call.
pub fn get(&self, property: impl AsArg<StringName>) -> Variant
pub fn get(&self, property: impl AsArg<StringName>) -> Variant
Returns the Variant value of the given property. If the property does not exist, this method returns null.
var node = Node2D.new()
node.rotation = 1.5
var a = node.get("rotation") # a is 1.5Note: In C#, property must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the PropertyName class to avoid allocating a new StringName on each call.
pub fn set_indexed(
&mut self,
property_path: impl AsArg<NodePath>,
value: &Variant,
)
pub fn set_indexed( &mut self, property_path: impl AsArg<NodePath>, value: &Variant, )
Assigns a new value to the property identified by the property_path. The path should be a NodePath relative to this object, and can use the colon character (:) to access nested properties.
var node = Node2D.new()
node.set_indexed("position", Vector2(42, 0))
node.set_indexed("position:y", -10)
print(node.position) # Prints (42.0, -10.0)Note: In C#, property_path must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the PropertyName class to avoid allocating a new StringName on each call.
pub fn get_indexed(&self, property_path: impl AsArg<NodePath>) -> Variant
pub fn get_indexed(&self, property_path: impl AsArg<NodePath>) -> Variant
Gets the object’s property indexed by the given property_path. The path should be a NodePath relative to the current object and can use the colon character (:) to access nested properties.
Examples: "position:x" or "material:next_pass:blend_mode".
var node = Node2D.new()
node.position = Vector2(5, -10)
var a = node.get_indexed("position") # a is Vector2(5, -10)
var b = node.get_indexed("position:y") # b is -10Note: In C#, property_path must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the PropertyName class to avoid allocating a new StringName on each call.
Note: This method does not support actual paths to nodes in the SceneTree, only sub-property paths. In the context of nodes, use get_node_and_resource instead.
pub fn get_property_list(&self) -> Array<Dictionary<Variant, Variant>>
pub fn get_property_list(&self) -> Array<Dictionary<Variant, Variant>>
Returns the object’s property list as an Array of dictionaries. Each Dictionary contains the following entries:
-
nameis the property’s name, as aString; -
class_nameis an emptyStringName, unless the property isVariantType::OBJECTand it inherits from a class; -
typeis the property’s type, as anint(see [enum Variant.Type]); -
hintis how the property is meant to be edited (see [enum PropertyHint]); -
hint_stringdepends on the hint (see [enum PropertyHint]); -
usageis a combination of [enum PropertyUsageFlags].
Note: In GDScript, all class members are treated as properties. In C# and GDExtension, it may be necessary to explicitly mark class members as Godot properties using decorators or attributes.
pub fn get_method_list(&self) -> Array<Dictionary<Variant, Variant>>
pub fn get_method_list(&self) -> Array<Dictionary<Variant, Variant>>
Returns this object’s methods and their signatures as an Array of dictionaries. Each Dictionary contains the following entries:
-
nameis the name of the method, as aString; -
argsis anArrayof dictionaries representing the arguments; -
default_argsis the default arguments as anArrayof variants; -
flagsis a combination of [enum MethodFlags]; -
idis the method’s internal identifierint; -
returnis the returned value, as aDictionary;
Note: The dictionaries of args and return are formatted identically to the results of get_property_list, although not all entries are used.
pub fn property_can_revert(&self, property: impl AsArg<StringName>) -> bool
pub fn property_can_revert(&self, property: impl AsArg<StringName>) -> bool
Returns true if the given property has a custom default value. Use property_get_revert to get the property’s default value.
Note: This method is used by the Inspector dock to display a revert icon. The object must implement [method _property_can_revert] to customize the default value. If [method _property_can_revert] is not implemented, this method returns false.
pub fn property_get_revert(&self, property: impl AsArg<StringName>) -> Variant
pub fn property_get_revert(&self, property: impl AsArg<StringName>) -> Variant
Returns the custom default value of the given property. Use property_can_revert to check if the property has a custom default value.
Note: This method is used by the Inspector dock to display a revert icon. The object must implement [method _property_get_revert] to customize the default value. If [method _property_get_revert] is not implemented, this method returns null.
pub fn set_meta(&mut self, name: impl AsArg<StringName>, value: &Variant)
pub fn set_meta(&mut self, name: impl AsArg<StringName>, value: &Variant)
Adds or changes the entry name inside the object’s metadata. The metadata value can be any Variant, although some types cannot be serialized correctly.
If value is null, the entry is removed. This is the equivalent of using remove_meta. See also has_meta and get_meta.
Note: A metadata’s name must be a valid identifier as per is_valid_identifier method.
Note: Metadata that has a name starting with an underscore (_) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.
pub fn remove_meta(&mut self, name: impl AsArg<StringName>)
pub fn remove_meta(&mut self, name: impl AsArg<StringName>)
Removes the given entry name from the object’s metadata. See also has_meta, get_meta and set_meta.
Note: A metadata’s name must be a valid identifier as per is_valid_identifier method.
Note: Metadata that has a name starting with an underscore (_) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.
pub fn get_meta(&self, name: impl AsArg<StringName>) -> Variant
pub fn get_meta(&self, name: impl AsArg<StringName>) -> Variant
To set the default parameters, use get_meta_ex and its builder methods. See the book for detailed usage instructions.
Returns the object’s metadata value for the given entry name. If the entry does not exist, returns default. If default is null, an error is also generated.
Note: A metadata’s name must be a valid identifier as per is_valid_identifier method.
Note: Metadata that has a name starting with an underscore (_) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.
pub fn get_meta_ex<'ex>(
&'ex self,
name: impl AsArg<StringName> + 'ex,
) -> ExGetMeta<'ex>
pub fn get_meta_ex<'ex>( &'ex self, name: impl AsArg<StringName> + 'ex, ) -> ExGetMeta<'ex>
Returns the object’s metadata value for the given entry name. If the entry does not exist, returns default. If default is null, an error is also generated.
Note: A metadata’s name must be a valid identifier as per is_valid_identifier method.
Note: Metadata that has a name starting with an underscore (_) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.
pub fn has_meta(&self, name: impl AsArg<StringName>) -> bool
pub fn has_meta(&self, name: impl AsArg<StringName>) -> bool
Returns true if a metadata entry is found with the given name. See also get_meta, set_meta and remove_meta.
Note: A metadata’s name must be a valid identifier as per is_valid_identifier method.
Note: Metadata that has a name starting with an underscore (_) is considered editor-only. Editor-only metadata is not displayed in the Inspector and should not be edited, although it can still be found by this method.
pub fn get_meta_list(&self) -> Array<StringName>
pub fn get_meta_list(&self) -> Array<StringName>
Returns the object’s metadata entry names as an Array of StringNames.
pub fn add_user_signal(&mut self, signal: impl AsArg<GString>)
pub fn add_user_signal(&mut self, signal: impl AsArg<GString>)
To set the default parameters, use add_user_signal_ex and its builder methods. See the book for detailed usage instructions.
Adds a user-defined signal named signal. Optional arguments for the signal can be added as an Array of dictionaries, each defining a name String and a type int (see [enum Variant.Type]). See also has_user_signal and remove_user_signal.
add_user_signal("hurt", [
{ "name": "damage", "type": TYPE_INT },
{ "name": "source", "type": TYPE_OBJECT }
])pub fn add_user_signal_ex<'ex>(
&'ex mut self,
signal: impl AsArg<GString> + 'ex,
) -> ExAddUserSignal<'ex>
pub fn add_user_signal_ex<'ex>( &'ex mut self, signal: impl AsArg<GString> + 'ex, ) -> ExAddUserSignal<'ex>
Adds a user-defined signal named signal. Optional arguments for the signal can be added as an Array of dictionaries, each defining a name String and a type int (see [enum Variant.Type]). See also has_user_signal and remove_user_signal.
add_user_signal("hurt", [
{ "name": "damage", "type": TYPE_INT },
{ "name": "source", "type": TYPE_OBJECT }
])pub fn has_user_signal(&self, signal: impl AsArg<StringName>) -> bool
pub fn has_user_signal(&self, signal: impl AsArg<StringName>) -> bool
Returns true if the given user-defined signal name exists. Only signals added with add_user_signal are included. See also remove_user_signal.
pub fn remove_user_signal(&mut self, signal: impl AsArg<StringName>)
pub fn remove_user_signal(&mut self, signal: impl AsArg<StringName>)
Removes the given user signal signal from the object. See also add_user_signal and has_user_signal.
pub fn emit_signal(
&mut self,
signal: impl AsArg<StringName>,
varargs: &[Variant],
) -> Error
pub fn emit_signal( &mut self, signal: impl AsArg<StringName>, varargs: &[Variant], ) -> Error
Emits the given signal by name. The signal must exist, so it should be a built-in signal of this class or one of its inherited classes, or a user-defined signal (see add_user_signal). This method supports a variable number of arguments, so parameters can be passed as a comma separated list.
Returns Error::ERR_UNAVAILABLE if signal does not exist or the parameters are invalid.
emit_signal("hit", "sword", 100)
emit_signal("game_over")Note: In C#, signal must be in snake_case when referring to built-in Godot signals. Prefer using the names exposed in the SignalName class to avoid allocating a new StringName on each call.
§Panics
This is a varcall method, meaning parameters and return values are passed as Variant.
It can detect call failures and will panic in such a case.
pub fn try_emit_signal(
&mut self,
signal: impl AsArg<StringName>,
varargs: &[Variant],
) -> Result<Error, CallError>
pub fn try_emit_signal( &mut self, signal: impl AsArg<StringName>, varargs: &[Variant], ) -> Result<Error, CallError>
§Return type
This is a varcall method, meaning parameters and return values are passed as Variant.
It can detect call failures and will return Err in such a case.
pub fn call(
&mut self,
method: impl AsArg<StringName>,
varargs: &[Variant],
) -> Variant
pub fn call( &mut self, method: impl AsArg<StringName>, varargs: &[Variant], ) -> Variant
Calls the method on the object and returns the result. This method supports a variable number of arguments, so parameters can be passed as a comma separated list.
var node = Node3D.new()
node.call("rotate", Vector3(1.0, 0.0, 0.0), 1.571)Note: In C#, method must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the MethodName class to avoid allocating a new StringName on each call.
§Panics
This is a varcall method, meaning parameters and return values are passed as Variant.
It can detect call failures and will panic in such a case.
pub fn try_call(
&mut self,
method: impl AsArg<StringName>,
varargs: &[Variant],
) -> Result<Variant, CallError>
pub fn try_call( &mut self, method: impl AsArg<StringName>, varargs: &[Variant], ) -> Result<Variant, CallError>
§Return type
This is a varcall method, meaning parameters and return values are passed as Variant.
It can detect call failures and will return Err in such a case.
pub fn call_deferred(
&mut self,
method: impl AsArg<StringName>,
varargs: &[Variant],
) -> Variant
pub fn call_deferred( &mut self, method: impl AsArg<StringName>, varargs: &[Variant], ) -> Variant
Calls the method on the object during idle time. Always returns null, not the method’s result.
Idle time happens mainly at the end of process and physics frames. In it, deferred calls will be run until there are none left, which means you can defer calls from other deferred calls and they’ll still be run in the current idle time cycle. This means you should not call a method deferred from itself (or from a method called by it), as this causes infinite recursion the same way as if you had called the method directly.
This method supports a variable number of arguments, so parameters can be passed as a comma separated list.
var node = Node3D.new()
node.call_deferred("rotate", Vector3(1.0, 0.0, 0.0), 1.571)For methods that are deferred from the same thread, the order of execution at idle time is identical to the order in which call_deferred was called.
See also call_deferred.
Note: In C#, method must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the MethodName class to avoid allocating a new StringName on each call.
Note: If you’re looking to delay the function call by a frame, refer to the SceneTree.process_frame and SceneTree.physics_frame signals.
var node = Node3D.new()
# Make a Callable and bind the arguments to the node's rotate() call.
var callable = node.rotate.bind(Vector3(1.0, 0.0, 0.0), 1.571)
# Connect the callable to the process_frame signal, so it gets called in the next process frame.
# CONNECT_ONE_SHOT makes sure it only gets called once instead of every frame.
get_tree().process_frame.connect(callable, CONNECT_ONE_SHOT)§Panics
This is a varcall method, meaning parameters and return values are passed as Variant.
It can detect call failures and will panic in such a case.
pub fn try_call_deferred(
&mut self,
method: impl AsArg<StringName>,
varargs: &[Variant],
) -> Result<Variant, CallError>
pub fn try_call_deferred( &mut self, method: impl AsArg<StringName>, varargs: &[Variant], ) -> Result<Variant, CallError>
§Return type
This is a varcall method, meaning parameters and return values are passed as Variant.
It can detect call failures and will return Err in such a case.
pub fn set_deferred(
&mut self,
property: impl AsArg<StringName>,
value: &Variant,
)
pub fn set_deferred( &mut self, property: impl AsArg<StringName>, value: &Variant, )
Assigns value to the given property, at the end of the current frame. This is equivalent to calling set through call_deferred.
var node = Node2D.new()
add_child(node)
node.rotation = 1.5
node.set_deferred("rotation", 3.0)
print(node.rotation) # Prints 1.5
await get_tree().process_frame
print(node.rotation) # Prints 3.0Note: In C#, property must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the PropertyName class to avoid allocating a new StringName on each call.
pub fn callv(
&mut self,
method: impl AsArg<StringName>,
arg_array: &AnyArray,
) -> Variant
pub fn callv( &mut self, method: impl AsArg<StringName>, arg_array: &AnyArray, ) -> Variant
Calls the method on the object and returns the result. Unlike call, this method expects all parameters to be contained inside arg_array.
var node = Node3D.new()
node.callv("rotate", [Vector3(1.0, 0.0, 0.0), 1.571])Note: In C#, method must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the MethodName class to avoid allocating a new StringName on each call.
pub fn has_method(&self, method: impl AsArg<StringName>) -> bool
pub fn has_method(&self, method: impl AsArg<StringName>) -> bool
Returns true if the given method name exists in the object.
Note: In C#, method must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the MethodName class to avoid allocating a new StringName on each call.
pub fn get_method_argument_count(&self, method: impl AsArg<StringName>) -> i32
pub fn get_method_argument_count(&self, method: impl AsArg<StringName>) -> i32
Returns the number of arguments of the given method by name.
Note: In C#, method must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the MethodName class to avoid allocating a new StringName on each call.
pub fn has_signal(&self, signal: impl AsArg<StringName>) -> bool
pub fn has_signal(&self, signal: impl AsArg<StringName>) -> bool
Returns true if the given signal name exists in the object.
Note: In C#, signal must be in snake_case when referring to built-in Godot signals. Prefer using the names exposed in the SignalName class to avoid allocating a new StringName on each call.
pub fn get_signal_list(&self) -> Array<Dictionary<Variant, Variant>>
pub fn get_signal_list(&self) -> Array<Dictionary<Variant, Variant>>
Returns the list of existing signals as an Array of dictionaries.
Note: Due to the implementation, each Dictionary is formatted very similarly to the returned values of get_method_list.
pub fn get_signal_connection_list(
&self,
signal: impl AsArg<StringName>,
) -> Array<Dictionary<Variant, Variant>>
pub fn get_signal_connection_list( &self, signal: impl AsArg<StringName>, ) -> Array<Dictionary<Variant, Variant>>
Returns an Array of connections for the given signal name. Each connection is represented as a Dictionary that contains three entries:
pub fn get_incoming_connections(&self) -> Array<Dictionary<Variant, Variant>>
pub fn get_incoming_connections(&self) -> Array<Dictionary<Variant, Variant>>
Returns an Array of signal connections received by this object. Each connection is represented as a Dictionary that contains three entries:
pub fn disconnect(
&mut self,
signal: impl AsArg<StringName>,
callable: &Callable,
)
pub fn disconnect( &mut self, signal: impl AsArg<StringName>, callable: &Callable, )
Disconnects a signal by name from a given callable. If the connection does not exist, generates an error. Use is_connected to make sure that the connection exists.
pub fn is_connected(
&self,
signal: impl AsArg<StringName>,
callable: &Callable,
) -> bool
pub fn is_connected( &self, signal: impl AsArg<StringName>, callable: &Callable, ) -> bool
Returns true if a connection exists between the given signal name and callable.
Note: In C#, signal must be in snake_case when referring to built-in Godot signals. Prefer using the names exposed in the SignalName class to avoid allocating a new StringName on each call.
pub fn has_connections(&self, signal: impl AsArg<StringName>) -> bool
pub fn has_connections(&self, signal: impl AsArg<StringName>) -> bool
Returns true if any connection exists on the given signal name.
Note: In C#, signal must be in snake_case when referring to built-in Godot methods. Prefer using the names exposed in the SignalName class to avoid allocating a new StringName on each call.
pub fn set_block_signals(&mut self, enable: bool)
pub fn set_block_signals(&mut self, enable: bool)
If set to true, the object becomes unable to emit signals. As such, emit_signal and signal connections will not work, until it is set to false.
pub fn is_blocking_signals(&self) -> bool
pub fn is_blocking_signals(&self) -> bool
Returns true if the object is blocking its signals from being emitted. See set_block_signals.
pub fn notify_property_list_changed(&mut self)
pub fn notify_property_list_changed(&mut self)
Emits the property_list_changed signal. This is mainly used to refresh the editor, so that the Inspector and editor plugins are properly updated.
pub fn set_message_translation(&mut self, enable: bool)
pub fn set_message_translation(&mut self, enable: bool)
If set to true, allows the object to translate messages with tr and tr_n. Enabled by default. See also can_translate_messages.
pub fn can_translate_messages(&self) -> bool
pub fn can_translate_messages(&self) -> bool
Returns true if the object is allowed to translate messages with tr and tr_n. See also set_message_translation.
pub fn tr(&self, message: impl AsArg<StringName>) -> GString
pub fn tr(&self, message: impl AsArg<StringName>) -> GString
To set the default parameters, use tr_ex and its builder methods. See the book for detailed usage instructions.
Translates a message, using the translation catalogs configured in the Project Settings. Further context can be specified to help with the translation. Note that most Control nodes automatically translate their strings, so this method is mostly useful for formatted strings or custom drawn text.
If can_translate_messages is false, or no translation is available, this method returns the message without changes. See set_message_translation.
For detailed examples, see Internationalizing games.
Note: This method can’t be used without an Object instance, as it requires the can_translate_messages method. To translate strings in a static context, use translate.
pub fn tr_ex<'ex>(&'ex self, message: impl AsArg<StringName> + 'ex) -> ExTr<'ex>
pub fn tr_ex<'ex>(&'ex self, message: impl AsArg<StringName> + 'ex) -> ExTr<'ex>
Translates a message, using the translation catalogs configured in the Project Settings. Further context can be specified to help with the translation. Note that most Control nodes automatically translate their strings, so this method is mostly useful for formatted strings or custom drawn text.
If can_translate_messages is false, or no translation is available, this method returns the message without changes. See set_message_translation.
For detailed examples, see Internationalizing games.
Note: This method can’t be used without an Object instance, as it requires the can_translate_messages method. To translate strings in a static context, use translate.
pub fn tr_n(
&self,
message: impl AsArg<StringName>,
plural_message: impl AsArg<StringName>,
n: i32,
) -> GString
pub fn tr_n( &self, message: impl AsArg<StringName>, plural_message: impl AsArg<StringName>, n: i32, ) -> GString
To set the default parameters, use tr_n_ex and its builder methods. See the book for detailed usage instructions.
Translates a message or plural_message, using the translation catalogs configured in the Project Settings. Further context can be specified to help with the translation.
If can_translate_messages is false, or no translation is available, this method returns message or plural_message, without changes. See set_message_translation.
The n is the number, or amount, of the message’s subject. It is used by the translation system to fetch the correct plural form for the current language.
For detailed examples, see Localization using gettext.
Note: Negative and float numbers may not properly apply to some countable subjects. It’s recommended to handle these cases with tr.
Note: This method can’t be used without an Object instance, as it requires the can_translate_messages method. To translate strings in a static context, use translate_plural.
pub fn tr_n_ex<'ex>(
&'ex self,
message: impl AsArg<StringName> + 'ex,
plural_message: impl AsArg<StringName> + 'ex,
n: i32,
) -> ExTrN<'ex>
pub fn tr_n_ex<'ex>( &'ex self, message: impl AsArg<StringName> + 'ex, plural_message: impl AsArg<StringName> + 'ex, n: i32, ) -> ExTrN<'ex>
Translates a message or plural_message, using the translation catalogs configured in the Project Settings. Further context can be specified to help with the translation.
If can_translate_messages is false, or no translation is available, this method returns message or plural_message, without changes. See set_message_translation.
The n is the number, or amount, of the message’s subject. It is used by the translation system to fetch the correct plural form for the current language.
For detailed examples, see Localization using gettext.
Note: Negative and float numbers may not properly apply to some countable subjects. It’s recommended to handle these cases with tr.
Note: This method can’t be used without an Object instance, as it requires the can_translate_messages method. To translate strings in a static context, use translate_plural.
pub fn get_translation_domain(&self) -> StringName
pub fn get_translation_domain(&self) -> StringName
Returns the name of the translation domain used by tr and tr_n. See also TranslationServer.
pub fn set_translation_domain(&mut self, domain: impl AsArg<StringName>)
pub fn set_translation_domain(&mut self, domain: impl AsArg<StringName>)
Sets the name of the translation domain used by tr and tr_n. See also TranslationServer.
pub fn is_queued_for_deletion(&self) -> bool
pub fn is_queued_for_deletion(&self) -> bool
Returns true if the queue_free method was called for the object.
pub fn cancel_free(&mut self)
pub fn cancel_free(&mut self)
If this method is called during ObjectNotification::PREDELETE, this object will reject being freed and will remain allocated. This is mostly an internal function used for error handling to avoid the user from freeing objects when they are not intended to.
pub fn notify(&mut self, what: ObjectNotification)
pub fn notify(&mut self, what: ObjectNotification)
⚠️ Sends a Godot notification to all classes inherited by the object.
Triggers calls to on_notification(), and depending on the notification, also to Godot’s lifecycle callbacks such as ready().
Starts from the highest ancestor (the Object class) and goes down the hierarchy.
See also Godot docs for Object::notification().
§Panics
If you call this method on a user-defined object while holding a GdRef or GdMut guard on the instance, you will encounter
a panic. The reason is that the receiving virtual method on_notification() acquires a GdMut lock dynamically, which must
be exclusive.
pub fn notify_reversed(&mut self, what: ObjectNotification)
pub fn notify_reversed(&mut self, what: ObjectNotification)
⚠️ Like Self::notify(), but starts at the most-derived class and goes up the hierarchy.
See docs of that method, including the panics.
Trait Implementations§
§impl Bounds for TextServer
impl Bounds for TextServer
§type Memory = MemRefCounted
type Memory = MemRefCounted
§type Declarer = DeclEngine
type Declarer = DeclEngine
§impl Debug for TextServer
impl Debug for TextServer
§impl Deref for TextServer
impl Deref for TextServer
§type Target = RefCounted
type Target = RefCounted
§fn deref(&self) -> &<TextServer as Deref>::Target
fn deref(&self) -> &<TextServer as Deref>::Target
§impl DerefMut for TextServer
impl DerefMut for TextServer
§fn deref_mut(&mut self) -> &mut <TextServer as Deref>::Target
fn deref_mut(&mut self) -> &mut <TextServer as Deref>::Target
§impl GodotClass for TextServer
impl GodotClass for TextServer
§const INIT_LEVEL: InitLevel = crate::init::InitLevel::Scene
const INIT_LEVEL: InitLevel = crate::init::InitLevel::Scene
§type Base = RefCounted
type Base = RefCounted
T. This is always a Godot engine class.§fn class_id() -> ClassId
fn class_id() -> ClassId
§fn inherits<Base>() -> boolwhere
Base: GodotClass,
fn inherits<Base>() -> boolwhere
Base: GodotClass,
§impl Inherits<Object> for TextServer
impl Inherits<Object> for TextServer
§const IS_SAME_CLASS: bool = false
const IS_SAME_CLASS: bool = false
Self == Base. Read more§impl Inherits<RefCounted> for TextServer
impl Inherits<RefCounted> for TextServer
§const IS_SAME_CLASS: bool = false
const IS_SAME_CLASS: bool = false
Self == Base. Read more§impl Inherits<TextServer> for TextServerAdvanced
impl Inherits<TextServer> for TextServerAdvanced
§const IS_SAME_CLASS: bool = false
const IS_SAME_CLASS: bool = false
Self == Base. Read more§impl Inherits<TextServer> for TextServerDummy
impl Inherits<TextServer> for TextServerDummy
§const IS_SAME_CLASS: bool = false
const IS_SAME_CLASS: bool = false
Self == Base. Read more§impl Inherits<TextServer> for TextServerExtension
impl Inherits<TextServer> for TextServerExtension
§const IS_SAME_CLASS: bool = false
const IS_SAME_CLASS: bool = false
Self == Base. Read more§impl WithSignals for TextServer
impl WithSignals for TextServer
§type SignalCollection<'c, C: WithSignals> = SignalsOfObject<'c, C>
type SignalCollection<'c, C: WithSignals> = SignalsOfObject<'c, C>
Auto Trait Implementations§
impl Freeze for TextServer
impl RefUnwindSafe for TextServer
impl !Send for TextServer
impl !Sync for TextServer
impl Unpin for TextServer
impl UnsafeUnpin for TextServer
impl UnwindSafe for TextServer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Inherits<T> for Twhere
T: GodotClass,
impl<T> Inherits<T> for Twhere
T: GodotClass,
§const IS_SAME_CLASS: bool = true
const IS_SAME_CLASS: bool = true
Self == Base. Read more