pub struct GlyphMap { /* private fields */ }Expand description
Cached character-to-glyph mapping for one font at one size.
Font::glyph_id re-reads the font’s tables on every call; per-frame text needs the
answer for thousands of characters, so this caches it: ASCII is resolved up front into
a table, any other character on first use (that first use allocates, later ones don’t).
Characters the font lacks map to its ? glyph.
Memory is bounded: after MAX_CACHED_CHARS distinct non-ASCII characters (streaming
text, CJK), the non-ASCII memory is cleared, keeping its capacity, and refilled on use.
Implementations§
Source§impl GlyphMap
impl GlyphMap
Sourcepub fn cached_chars(&self) -> usize
pub fn cached_chars(&self) -> usize
Non-ASCII characters currently remembered (at most MAX_CACHED_CHARS).
Sourcepub fn line_metrics(&self) -> LineMetrics
pub fn line_metrics(&self) -> LineMetrics
The font’s line metrics at this size.
Sourcepub fn get(&mut self, ch: char) -> Option<MappedGlyph>
pub fn get(&mut self, ch: char) -> Option<MappedGlyph>
The glyph for ch, or the ? glyph if the font has none; None only if the font
lacks ? too.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for GlyphMap
impl !UnwindSafe for GlyphMap
impl Freeze for GlyphMap
impl Send for GlyphMap
impl Sync for GlyphMap
impl Unpin for GlyphMap
impl UnsafeUnpin for GlyphMap
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
Mutably borrows from an owned value. Read more