pub struct FontAtlas { /* private fields */ }Expand description
A texture atlas containing font glyphs for efficient WebGL text rendering.
FontAtlas manages a WebGL 2D texture array where each layer contains a single
character glyph. This design enables efficient instanced rendering of text by
allowing the GPU to select the appropriate character layer for each rendered cell.
§Architecture
The atlas uses a WebGL 2D texture array where:
- Each layer contains one character glyph
- ASCII characters use their ASCII value as the layer index
- Non-ASCII characters are stored in a hash map for layer lookup
- All glyphs have uniform cell dimensions for consistent spacing
Implementations§
Source§impl FontAtlas
impl FontAtlas
Sourcepub fn load_default(gl: &WebGl2RenderingContext) -> Result<Self, Error>
pub fn load_default(gl: &WebGl2RenderingContext) -> Result<Self, Error>
Loads the default embedded font atlas.
Sourcepub fn load(
gl: &WebGl2RenderingContext,
config: FontAtlasData,
) -> Result<Self, Error>
pub fn load( gl: &WebGl2RenderingContext, config: FontAtlasData, ) -> Result<Self, Error>
Creates a TextureAtlas from a grid of equal-sized cells
Sourcepub fn bind(&self, gl: &WebGl2RenderingContext, texture_unit: u32)
pub fn bind(&self, gl: &WebGl2RenderingContext, texture_unit: u32)
Binds the atlas texture to the specified texture unit
pub fn cell_size(&self) -> (i32, i32)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FontAtlas
impl RefUnwindSafe for FontAtlas
impl !Send for FontAtlas
impl !Sync for FontAtlas
impl Unpin for FontAtlas
impl UnwindSafe for FontAtlas
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