Struct kas_text::fonts::FontLibrary [−][src]
pub struct FontLibrary { /* fields omitted */ }Expand description
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
Font management
Get mutable access to the font database
This can be used to adjust font selection. Note that any changes only
affect new font selections, thus it is recommended only to adjust the
database before any fonts have been selected. No existing FaceId
or FontId will be affected by this; additionally any
FontSelector which has already been selected will continue to
resolve the existing FontId via the cache.
Get the first face for a font
Assumes that font_id is valid; if not the method will panic.
Each font identifier has at least one font face. This resolves the first (default) one.
Get the first face for a font
This is a wrapper around FontLibrary::first_face_for and FontLibrary::get_face.
Resolve the face for a character
This selects the first face containing this glyph from the font list.
Resolve the face for a character
This selects the first face containing this glyph from the font list, otherwise choosing the first face.
Select the default font
If FontId(0) has not been defined yet, this sets the default font,
otherwise it does nothing.
This must be called (at least once) before any other font-loading method, and before querying any font-derived properties (such as text dimensions).
Select a font
This method uses internal caching to enable fast look-ups of existing (loaded) fonts. Resolving new fonts may be slower.
Face management
Get a font face from its identifier
Panics if id is not valid (required: id.get() < self.num_faces()).
Get the number of loaded font faces
FaceId values are indices assigned consecutively and are permanent.
For any x < self.num_faces(), FaceId(x) is a valid font face 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.
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.
Auto Trait Implementations
impl RefUnwindSafe for FontLibraryimpl Send for FontLibraryimpl Sync for FontLibraryimpl Unpin for FontLibraryimpl UnwindSafe for FontLibraryBlanket Implementations
Mutably borrows from an owned value. Read more
Cast to integer, truncating Read more
Cast to the nearest integer Read more
Cast the floor to an integer Read more
Try converting to integer with truncation Read more
Try converting to the nearest integer Read more
Try converting the floor to an integer Read more
Try convert the ceiling to an integer Read more