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
.
Otherwise (if no face covers c
) return None
.
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 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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more