[][src]Struct gdnative::api::BitmapFont

pub struct BitmapFont { /* fields omitted */ }

core class BitmapFont 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

BitmapFont 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 BitmapFont[src]

pub fn new() -> Ref<BitmapFont, 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_char(
    &self,
    character: i64,
    texture: i64,
    rect: Rect<f32, UnknownUnit>,
    align: Vector2D<f32, UnknownUnit>,
    advance: f64
)
[src]

Adds a character to the font, where [code]character[/code] is the Unicode value, [code]texture[/code] is the texture index, [code]rect[/code] is the region in the texture (in pixels!), [code]align[/code] is the (optional) alignment for the character and [code]advance[/code] is the (optional) advance.

Default Arguments

  • align - Vector2( 0, 0 )
  • advance - -1

pub fn add_kerning_pair(&self, char_a: i64, char_b: i64, kerning: i64)[src]

Adds a kerning pair to the [BitmapFont] as a difference. Kerning pairs are special cases where a typeface advance is determined by the next character.

pub fn add_texture(&self, texture: impl AsArg<Texture>)[src]

Adds a texture to the [BitmapFont].

pub fn clear(&self)[src]

Clears all the font data and settings.

pub fn create_from_fnt(
    &self,
    path: impl Into<GodotString>
) -> Result<(), GodotError>
[src]

Creates a BitmapFont from the [code]*.fnt[/code] file at [code]path[/code].

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

The fallback font.

pub fn get_kerning_pair(&self, char_a: i64, char_b: i64) -> i64[src]

Returns a kerning pair as a difference.

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

Returns the font atlas texture at index [code]idx[/code].

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

Returns the number of textures in the BitmapFont atlas.

pub fn set_ascent(&self, px: f64)[src]

Ascent (number of pixels above the baseline).

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

If [code]true[/code], distance field hint is enabled.

pub fn set_fallback(&self, fallback: impl AsArg<BitmapFont>)[src]

The fallback font.

pub fn set_height(&self, px: f64)[src]

Total font height (ascent plus descent) in pixels.

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 BitmapFont[src]

impl Deref for BitmapFont[src]

type Target = Font

The resulting type after dereferencing.

impl DerefMut for BitmapFont[src]

impl GodotObject for BitmapFont[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 BitmapFont[src]

impl SubClass<Font> for BitmapFont[src]

impl SubClass<Object> for BitmapFont[src]

impl SubClass<Reference> for BitmapFont[src]

impl SubClass<Resource> for BitmapFont[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.