pub struct FontLibrary { /* private fields */ }Expand description
Library of loaded fonts
This is the type of the global singleton accessible via the library()
function. Thread-safety is handled via internal locks.
Implementations§
Source§impl FontLibrary
Font management
impl FontLibrary
Font management
Sourcepub fn resolver(&self) -> MutexGuard<'_, Resolver>
pub fn resolver(&self) -> MutexGuard<'_, Resolver>
Get a reference to the font resolver
Sourcepub fn first_face_for(&self, font_id: FontId) -> Result<FaceId, InvalidFontId>
pub fn first_face_for(&self, font_id: FontId) -> Result<FaceId, InvalidFontId>
Get the first face for a font
Each font identifier has at least one font face. This resolves the first (default) one.
Sourcepub fn get_first_face(
&self,
font_id: FontId,
) -> Result<FaceRef<'_>, InvalidFontId>
pub fn get_first_face( &self, font_id: FontId, ) -> Result<FaceRef<'_>, InvalidFontId>
Get the first face for a font
This is a wrapper around FontLibrary::first_face_for and FontLibrary::get_face.
Sourcepub fn contains_face(
&self,
font_id: FontId,
face_id: FaceId,
) -> Result<bool, InvalidFontId>
pub fn contains_face( &self, font_id: FontId, face_id: FaceId, ) -> Result<bool, InvalidFontId>
Sourcepub fn face_for_char(
&self,
font_id: FontId,
last_face_id: Option<FaceId>,
c: char,
) -> Result<Option<FaceId>, InvalidFontId>
pub fn face_for_char( &self, font_id: FontId, last_face_id: Option<FaceId>, c: char, ) -> Result<Option<FaceId>, InvalidFontId>
Resolve the font face for a character
If last_face_id is a face used by font_id and this face covers c,
then return last_face_id. (This is to avoid changing the font face
unnecessarily, such as when encountering a space amid Arabic text.)
Otherwise, return the first face of font_id which covers c.
Sourcepub fn select_font(
&self,
selector: &FontSelector,
script: Script,
) -> Result<FontId, NoFontMatch>
pub fn select_font( &self, selector: &FontSelector, script: Script, ) -> Result<FontId, NoFontMatch>
Select a font
This method uses internal caching to enable fast look-ups of existing (loaded) fonts. Resolving new fonts may be slower.
Source§impl FontLibrary
Face management
impl FontLibrary
Face management
Sourcepub fn get_face(&self, id: FaceId) -> FaceRef<'static>
pub fn get_face(&self, id: FaceId) -> FaceRef<'static>
Get a font face from its identifier
Panics if id is not valid (required: id.get() < self.num_faces()).
Sourcepub fn get_face_store(&self, id: FaceId) -> &'static FaceStore
pub fn get_face_store(&self, id: FaceId) -> &'static FaceStore
Get access to the FaceStore
Panics if id is not valid (required: id.get() < self.num_faces()).