pub struct FontGroup {
descriptor: FontDescriptor,
families: SmallVec<[FontGroupFamily; 8]>,
last_matching_fallback: Option<FontRef>,
}
Expand description
A FontGroup
is a prioritised list of fonts for a given set of font styles. It is used by
TextRun
to decide which font to render a character with. If none of the fonts listed in the
styles are suitable, a fallback font may be used.
Fields§
§descriptor: FontDescriptor
§families: SmallVec<[FontGroupFamily; 8]>
§last_matching_fallback: Option<FontRef>
Implementations§
source§impl FontGroup
impl FontGroup
pub fn new(style: &FontStyleStruct, descriptor: FontDescriptor) -> FontGroup
sourcepub fn find_by_codepoint(
&mut self,
font_context: &FontContext,
codepoint: char,
next_codepoint: Option<char>,
) -> Option<FontRef>
pub fn find_by_codepoint( &mut self, font_context: &FontContext, codepoint: char, next_codepoint: Option<char>, ) -> Option<FontRef>
Finds the first font, or else the first fallback font, which contains a glyph for
codepoint
. If no such font is found, returns the first available font or fallback font
(which will cause a “glyph not found” character to be rendered). If no font at all can be
found, returns None.
sourcepub fn first(&mut self, font_context: &FontContext) -> Option<FontRef>
pub fn first(&mut self, font_context: &FontContext) -> Option<FontRef>
Find the first available font in the group, or the first available fallback font.
sourcefn find<TemplatePredicate, FontPredicate>(
&mut self,
font_context: &FontContext,
template_predicate: TemplatePredicate,
font_predicate: FontPredicate,
) -> Option<FontRef>
fn find<TemplatePredicate, FontPredicate>( &mut self, font_context: &FontContext, template_predicate: TemplatePredicate, font_predicate: FontPredicate, ) -> Option<FontRef>
Attempts to find a font which matches the given template_predicate
and font_predicate
.
This method mutates because we may need to load new font data in the process of finding
a suitable font.
sourcefn find_fallback<TemplatePredicate, FontPredicate>(
&mut self,
font_context: &FontContext,
options: FallbackFontSelectionOptions,
template_predicate: TemplatePredicate,
font_predicate: FontPredicate,
) -> Option<FontRef>
fn find_fallback<TemplatePredicate, FontPredicate>( &mut self, font_context: &FontContext, options: FallbackFontSelectionOptions, template_predicate: TemplatePredicate, font_predicate: FontPredicate, ) -> Option<FontRef>
Attempts to find a suitable fallback font which matches the given template_predicate
and
font_predicate
. The default family (i.e. “serif”) will be tried first, followed by
platform-specific family names. If a codepoint
is provided, then its Unicode block may be
used to refine the list of family names which will be tried.
Trait Implementations§
source§impl MallocSizeOf for FontGroup
impl MallocSizeOf for FontGroup
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Auto Trait Implementations§
impl Freeze for FontGroup
impl !RefUnwindSafe for FontGroup
impl Send for FontGroup
impl Sync for FontGroup
impl Unpin for FontGroup
impl !UnwindSafe for FontGroup
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<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