[][src]Struct kas::text::fonts::FontLibrary

pub struct FontLibrary { /* fields omitted */ }

Library of loaded fonts

This is the type of the global singleton accessible via the fonts function. Thread-safety is handled via internal locks.

Implementations

impl FontLibrary[src]

pub fn get(&self, id: FontId) -> FaceRef[src]

Get a font from its identifier

Panics if id is not valid (required: id.get() < self.num_fonts()).

pub fn num_fonts(&self) -> usize[src]

Get the number of loaded font faces

FontId values are indices assigned consecutively and are permanent. For any x < self.num_fonts(), FontId(x) is a valid font identifier.

Font faces may be loaded on demand (by crate::Text::prepare but are never unloaded or adjusted, hence this value may increase but not decrease.

pub fn font_data(&'a self) -> FontData<'a>[src]

Access loaded font data

pub fn load_default(&self) -> Result<FontId, Box<dyn Error + 'static, Global>>[src]

Load a default font

This must be called before any other font-loading method.

This should be at least once before attempting to query any font-derived properties (such as text dimensions).

pub fn load_font(
    &self,
    selector: &FontSelector
) -> Result<FontId, Box<dyn Error + 'static, Global>>
[src]

Load a font

This method uses two levels of caching to resolve existing fonts, thus is suitable for repeated usage.

pub fn load_pathbuf(
    &self,
    path: PathBuf,
    index: u32,
    sel_hash: u64
) -> Result<FontId, Box<dyn Error + 'static, Global>>
[src]

Load a font by path

In case the (path, index) combination has already been loaded, the existing font object's FontId will be returned.

The index is used to select fonts from a font-collection. If the font is not a collection, use 0.

sel_hash is the hash of the FontSelector used; if this is not used, pass 0.

Auto Trait Implementations

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.