[][src]Struct rusttype::FontCollection

pub struct FontCollection<'a>(_);

A collection of fonts read straight from a font file's data. The data in the collection is not validated. This structure may or may not own the font data.

Lifetime

The lifetime reflects the font data lifetime. FontCollection<'static> covers most cases ie both dynamically loaded owned data and for referenced compile time font data.

Methods

impl<'a> FontCollection<'a>
[src]

Constructs a font collection from an array of bytes, typically loaded from a font file, which may be a single font or a TrueType Collection holding a number of fonts. This array may be owned (e.g. Vec<u8>), or borrowed (&[u8]). As long as From<T> is implemented for Bytes for some type T, T can be used as input.

This returns an error if bytes does not seem to be font data in a format we recognize.

If this FontCollection holds a single font, or a TrueType Collection containing only one font, return that as a Font. The FontCollection is consumed.

If this FontCollection holds multiple fonts, return a CollectionContainsMultipleFonts error.

If an error occurs, the FontCollection is lost, since this function takes ownership of it, and the error values don't give it back. If that is a problem, use the font_at or into_fonts methods instead, which borrow the FontCollection rather than taking ownership of it.

Gets the font at index i in the font collection, if it exists and is valid. The produced font borrows the font data that is either borrowed or owned by this font collection.

Important traits for IntoFontsIter<'a>

Converts self into an Iterator yielding each Font that exists within the collection.

Trait Implementations

impl<'a> Clone for FontCollection<'a>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'a> Debug for FontCollection<'a>
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'a> Send for FontCollection<'a>

impl<'a> Sync for FontCollection<'a>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more