Struct fontdue_sdl2::FontTexture [−][src]
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]
texture_creator: &'r TextureCreator<T>
) -> Result<FontTexture<'r>, String>
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]
&mut self,
canvas: &mut Canvas<RT>,
fonts: &[Font],
glyphs: &[GlyphPosition<Color>]
) -> Result<(), String>
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,