pub struct FontCollection<'a>(_);
Expand description

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.

Implementations

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.

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

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.