Struct fontdue_sdl2::FontTexture[][src]

pub struct FontTexture<'r> {
    pub texture: Texture<'r>,
    // some fields omitted
}

A text-rendering-enabled wrapper for Texture.

Fields

texture: Texture<'r>

The texture containing rendered glyphs in a tightly packed manner.

Implementations

impl FontTexture<'_>[src]

pub fn new<'r, T>(
    texture_creator: &'r TextureCreator<T>
) -> Result<FontTexture<'r>, String>
[src]

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.

pub fn draw_text<RT: RenderTarget>(
    &mut self,
    canvas: &mut Canvas<RT>,
    fonts: &[Font],
    glyphs: &[GlyphPosition<Color>]
) -> Result<(), String>
[src]

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

impl<'r> RefUnwindSafe for FontTexture<'r>

impl<'r> !Send for FontTexture<'r>

impl<'r> !Sync for FontTexture<'r>

impl<'r> Unpin for FontTexture<'r>

impl<'r> UnwindSafe for FontTexture<'r>

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, 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.