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()).
Auto Trait Implementations§
impl !Freeze for FontLibrary
impl RefUnwindSafe for FontLibrary
impl Send for FontLibrary
impl Sync for FontLibrary
impl Unpin for FontLibrary
impl UnsafeUnpin for FontLibrary
impl UnwindSafe for FontLibrary
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
Source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
Source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
Source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.