pub struct FontTexture<'r> {
    pub texture: Texture<'r>,
    /* private fields */
}
Expand description

A text-rendering-enabled wrapper for Texture.

Fields

texture: Texture<'r>

The texture containing rendered glyphs in a tightly packed manner.

Implementations

Creates a new FontTexture for rendering text.

Consider the lifetimes of this structure and the given TextureCreator as you would a Texture created with one, that is why this structure is named “FontTexture”.

Important note

Only use a single &[Font] for each FontTexture. Glyphs with the same index but different font are hard to differentiate, so using different sets of Fonts when rendering with a single FontTexture will lead to wrong results.

Errors

The function will return an error if the Texture can’t be created, and the Err(String) will contain an error string from SDL.

Renders text to the given canvas, using the given fonts and glyphs.

The canvas should be the same one that the TextureCreator used in FontTexture::new was created from.

The font-slice should be the same one that is passed to Layout::append.

The glyphs should be from Layout::glyphs.

Errors

This function will return an error if the Texture cannot be written to, or a copy from the texture to the canvas fails. This should only really happen under very exceptional circumstances, so text rendering is interrupted by these errors. The Err(String) will contain an informational string from SDL.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.