[][src]Struct gdnative::api::DynamicFont

pub struct DynamicFont { /* fields omitted */ }

core class DynamicFont inherits Font (reference counted).

Official documentation

See the documentation of this class in the Godot engine's official documentation.

Memory management

The lifetime of this object is automatically managed through reference counting.

Class hierarchy

DynamicFont inherits methods from:

Safety

All types in the Godot API have "interior mutability" in Rust parlance. To enforce that the official thread-safety guidelines are followed, the typestate pattern is used in the Ref and TRef smart pointers, and the Instance API. The typestate Access in these types tracks whether the access is unique, shared, or exclusive to the current thread. For more information, see the type-level documentation on Ref.

Implementations

impl DynamicFont[src]

Constants

impl DynamicFont[src]

pub fn new() -> Ref<DynamicFont, Unique>[src]

Creates a new instance of this object.

This is a reference-counted type. The returned object is automatically managed by Ref.

pub fn add_fallback(&self, data: impl AsArg<DynamicFontData>)[src]

Adds a fallback font.

pub fn get_available_chars(&self) -> GodotString[src]

Returns a string containing all the characters available in the main and all the fallback fonts.
				If a given character is included in more than one font, it appears only once in the returned string.

pub fn get_fallback(&self, idx: i64) -> Option<Ref<DynamicFontData, Shared>>[src]

Returns the fallback font at index [code]idx[/code].

pub fn get_fallback_count(&self) -> i64[src]

Returns the number of fallback fonts.

pub fn font_data(&self) -> Option<Ref<DynamicFontData, Shared>>[src]

The font data.

pub fn outline_color(&self) -> Color[src]

The font outline's color.
			[b]Note:[/b] It's recommended to leave this at the default value so that you can adjust it in individual controls. For example, if the outline is made black here, it won't be possible to change its color using a Label's font outline modulate theme item.

pub fn outline_size(&self) -> i64[src]

The font outline's thickness in pixels (not relative to the font size).

pub fn size(&self) -> i64[src]

The font size in pixels.

pub fn spacing(&self, _type: i64) -> i64[src]

Extra spacing at the top in pixels.

pub fn use_filter(&self) -> bool[src]

If [code]true[/code], filtering is used. This makes the font blurry instead of pixelated when scaling it if font oversampling is disabled or ineffective. It's recommended to enable this when using the font in a control whose size changes over time, unless a pixel art aesthetic is desired.

pub fn use_mipmaps(&self) -> bool[src]

If [code]true[/code], mipmapping is used. This improves the font's appearance when downscaling it if font oversampling is disabled or ineffective.

pub fn remove_fallback(&self, idx: i64)[src]

Removes the fallback font at index [code]idx[/code].

pub fn set_fallback(&self, idx: i64, data: impl AsArg<DynamicFontData>)[src]

Sets the fallback font at index [code]idx[/code].

pub fn set_font_data(&self, data: impl AsArg<DynamicFontData>)[src]

The font data.

pub fn set_outline_color(&self, color: Color)[src]

The font outline's color.
			[b]Note:[/b] It's recommended to leave this at the default value so that you can adjust it in individual controls. For example, if the outline is made black here, it won't be possible to change its color using a Label's font outline modulate theme item.

pub fn set_outline_size(&self, size: i64)[src]

The font outline's thickness in pixels (not relative to the font size).

pub fn set_size(&self, data: i64)[src]

The font size in pixels.

pub fn set_spacing(&self, _type: i64, value: i64)[src]

Extra spacing at the top in pixels.

pub fn set_use_filter(&self, enable: bool)[src]

If [code]true[/code], filtering is used. This makes the font blurry instead of pixelated when scaling it if font oversampling is disabled or ineffective. It's recommended to enable this when using the font in a control whose size changes over time, unless a pixel art aesthetic is desired.

pub fn set_use_mipmaps(&self, enable: bool)[src]

If [code]true[/code], mipmapping is used. This improves the font's appearance when downscaling it if font oversampling is disabled or ineffective.

Methods from Deref<Target = Font>

pub fn draw(
    &self,
    canvas_item: Rid,
    position: Vector2D<f32, UnknownUnit>,
    string: impl Into<GodotString>,
    modulate: Color,
    clip_w: i64,
    outline_modulate: Color
)
[src]

Draw [code]string[/code] into a canvas item using the font at a given position, with [code]modulate[/code] color, and optionally clipping the width. [code]position[/code] specifies the baseline, not the top. To draw from the top, [i]ascent[/i] must be added to the Y axis.
				See also [method CanvasItem.draw_string].

Default Arguments

  • modulate - Color( 1, 1, 1, 1 )
  • clip_w - -1
  • outline_modulate - Color( 1, 1, 1, 1 )

pub fn draw_char(
    &self,
    canvas_item: Rid,
    position: Vector2D<f32, UnknownUnit>,
    char: i64,
    next: i64,
    modulate: Color,
    outline: bool
) -> f64
[src]

Draw character [code]char[/code] into a canvas item using the font at a given position, with [code]modulate[/code] color, and optionally kerning if [code]next[/code] is passed. clipping the width. [code]position[/code] specifies the baseline, not the top. To draw from the top, [i]ascent[/i] must be added to the Y axis. The width used by the character is returned, making this function useful for drawing strings character by character.

Default Arguments

  • next - -1
  • modulate - Color( 1, 1, 1, 1 )
  • outline - false

pub fn get_ascent(&self) -> f64[src]

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

pub fn get_char_size(&self, char: i64, next: i64) -> Vector2D<f32, UnknownUnit>[src]

Returns the size of a character, optionally taking kerning into account if the next character is provided.

Default Arguments

  • next - 0

pub fn get_descent(&self) -> f64[src]

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

pub fn get_height(&self) -> f64[src]

Returns the total font height (ascent plus descent) in pixels.

pub fn get_string_size(
    &self,
    string: impl Into<GodotString>
) -> Vector2D<f32, UnknownUnit>
[src]

Returns the size of a string, taking kerning and advance into account.

pub fn get_wordwrap_string_size(
    &self,
    string: impl Into<GodotString>,
    width: f64
) -> Vector2D<f32, UnknownUnit>
[src]

Returns the size that the string would have with word wrapping enabled with a fixed [code]width[/code].

pub fn has_outline(&self) -> bool[src]

Returns [code]true[/code] if the font has an outline.

pub fn is_distance_field_hint(&self) -> bool[src]

pub fn update_changes(&self)[src]

After editing a font (changing size, ascent, char rects, etc.). Call this function to propagate changes to controls that might use it.

Trait Implementations

impl Debug for DynamicFont[src]

impl Deref for DynamicFont[src]

type Target = Font

The resulting type after dereferencing.

impl DerefMut for DynamicFont[src]

impl GodotObject for DynamicFont[src]

type RefKind = RefCounted

The memory management kind of this type. This modifies the behavior of the Ref smart pointer. See its type-level documentation for more information. Read more

impl Instanciable for DynamicFont[src]

impl SubClass<Font> for DynamicFont[src]

impl SubClass<Object> for DynamicFont[src]

impl SubClass<Reference> for DynamicFont[src]

impl SubClass<Resource> for DynamicFont[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SubClass<T> for T where
    T: GodotObject
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.