[][src]Struct tetra::graphics::text::Font

pub struct Font { /* fields omitted */ }

A font with an associated size, cached on the GPU.

Performance

Creating a Font is a relatively expensive operation. If you can, store them in your State struct rather than recreating them each frame.

Cloning a Font is a very cheap operation, as the underlying data is shared between the original instance and the clone via reference-counting.

Examples

The text example demonstrates how to load a font and then draw some text.

Implementations

impl Font[src]

pub fn vector<P>(ctx: &mut Context, path: P, size: f32) -> Result<Font> where
    P: AsRef<Path>, 
[src]

Creates a Font from a vector font file, with the given size.

TrueType and OpenType fonts are supported.

If you want to load multiple sizes of the same font, you can use a VectorFontBuilder to avoid loading/parsing the file multiple times.

Errors

Trait Implementations

impl Clone for Font[src]

impl Debug for Font[src]

Auto Trait Implementations

impl !RefUnwindSafe for Font

impl !Send for Font

impl !Sync for Font

impl Unpin for Font

impl !UnwindSafe for Font

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.