pub struct GlyphAtlas { /* private fields */ }Expand description
A static FontChain plus the char -> slot map for its grid-packed atlas.
Every glyph of every font in the chain is uploaded once; a character maps to a flat slot, which
is the font’s base offset in the atlas plus that font’s own glyph index. A renderer never sees
characters past this point: resolve hands back a u16 that goes straight
into an instance buffer.
Implementations§
Source§impl GlyphAtlas
impl GlyphAtlas
Sourcepub fn new(fonts: FontChain<'static>, glyph_size: (u8, u8)) -> Self
pub fn new(fonts: FontChain<'static>, glyph_size: (u8, u8)) -> Self
An atlas over a static font chain, whose slots are assigned back to back in chain order.
glyph_size is the cell size every font in fonts agrees on. Pass what
FontChain::glyph_size returned, and reject a chain it returned None for: a grid has
one cell size, so a chain whose fonts disagree has no atlas geometry to build.
Sourcepub const fn space_slot(&self) -> u16
pub const fn space_slot(&self) -> u16
The atlas slot of the space glyph, or 0 for a chain with no space glyph at all.
Only ever used for cells that draw no glyph (a backend still needs some slot in the instance it writes), so a chain without a space still renders correctly.
Sourcepub fn slot_count(&self) -> u32
pub fn slot_count(&self) -> u32
Sourcepub fn data(&self) -> AtlasData
pub fn data(&self) -> AtlasData
The full coverage buffer to upload, built fresh each call.
Not cached: a backend uploads it once at resource creation and, on some platforms, again after a lost device, which is rare enough that holding a second copy of the atlas for the renderer’s whole life costs more than rebuilding it.
Sourcepub fn resolve(&self, ch: char) -> Option<u16>
pub fn resolve(&self, ch: char) -> Option<u16>
Resolves ch to its atlas slot, or None when no font in the chain can draw it, not even
as the substituted solid block, in which case the caller draws no glyph for that cell.
§Panics
Does not panic. The u16 cast cannot truncate for a chain whose
slot_count is within MAX_SLOTS, which a backend’s builder is
expected to have checked.
Trait Implementations§
Source§impl Clone for GlyphAtlas
impl Clone for GlyphAtlas
Source§fn clone(&self) -> GlyphAtlas
fn clone(&self) -> GlyphAtlas
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for GlyphAtlas
impl RefUnwindSafe for GlyphAtlas
impl Send for GlyphAtlas
impl Sync for GlyphAtlas
impl Unpin for GlyphAtlas
impl UnsafeUnpin for GlyphAtlas
impl UnwindSafe for GlyphAtlas
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.