pub struct FallbackFontChain<'a> { /* private fields */ }Expand description
Combines a primary BitmapFont with an ordered list of fallback fonts.
resolve tries the primary font’s char mapping first; on a miss, it
tries each fallback font in order; only if every font in the chain misses does it fall
back to the primary font’s solid-block glyph. This lets a caller layer, say, an ASCII
or partial-coverage primary font with one or more broader fallback fonts, so a char
missing from the primary doesn’t automatically become a solid block if some other font
in the chain actually has it.
This type ships no bundled fallback font data – every font in the chain, primary or fallback, is supplied by the caller. Bundling a ready-to-use Latin-1/Extended fallback font is a natural follow-up now that this mechanism exists, but is out of scope here.
Callers who don’t need a fallback chain can keep using a bare BitmapFont and
BitmapFont::char_to_index/BitmapFont::rows directly, exactly as before –
this type is purely additive and opt-in.
Implementations§
Source§impl<'a> FallbackFontChain<'a>
impl<'a> FallbackFontChain<'a>
Sourcepub const fn new(primary: BitmapFont, fallbacks: &'a [BitmapFont]) -> Self
pub const fn new(primary: BitmapFont, fallbacks: &'a [BitmapFont]) -> Self
Constructs a chain from a primary font and an ordered list of fallback fonts.
Sourcepub fn resolve(&self, ch: char) -> ResolvedGlyph
pub fn resolve(&self, ch: char) -> ResolvedGlyph
Resolves ch to a glyph, trying the primary font first, then each fallback font
in order, only substituting the primary font’s solid-block glyph if every font in
the chain misses.
Trait Implementations§
Source§impl<'a> Clone for FallbackFontChain<'a>
impl<'a> Clone for FallbackFontChain<'a>
Source§fn clone(&self) -> FallbackFontChain<'a>
fn clone(&self) -> FallbackFontChain<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'a> Copy for FallbackFontChain<'a>
Auto Trait Implementations§
impl<'a> Freeze for FallbackFontChain<'a>
impl<'a> RefUnwindSafe for FallbackFontChain<'a>
impl<'a> Send for FallbackFontChain<'a>
impl<'a> Sync for FallbackFontChain<'a>
impl<'a> Unpin for FallbackFontChain<'a>
impl<'a> UnsafeUnpin for FallbackFontChain<'a>
impl<'a> UnwindSafe for FallbackFontChain<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.