[−][src]Struct kas::text::fonts::FontLibrary
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]
&self,
selector: &FontSelector
) -> Result<FontId, Box<dyn Error + 'static, Global>>
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]
&self,
path: PathBuf,
index: u32,
sel_hash: u64
) -> Result<FontId, Box<dyn Error + 'static, Global>>
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
impl RefUnwindSafe for FontLibrary
impl Send for FontLibrary
impl Sync for FontLibrary
impl Unpin for FontLibrary
impl UnwindSafe for FontLibrary
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>,