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)
Sourcepub fn underline(&self) -> LineDecoration
pub fn underline(&self) -> LineDecoration
Returns the underline configuration
Sourcepub fn strikethrough(&self) -> LineDecoration
pub fn strikethrough(&self) -> LineDecoration
Returns the strikethrough configuration
Sourcepub fn get_symbol(&self, glyph_id: u16) -> Option<Cow<'_, str>>
pub fn get_symbol(&self, glyph_id: u16) -> Option<Cow<'_, str>>
Returns the symbol for the given glyph ID, if it exists
Sourcepub fn get_base_glyph_id(&self, key: &str) -> Option<u16>
pub fn get_base_glyph_id(&self, key: &str) -> Option<u16>
Returns the base glyph identifier for the given key
Sourcepub fn glyph_tracker(&self) -> &GlyphTracker
pub fn glyph_tracker(&self) -> &GlyphTracker
Returns a reference to the glyph tracker for accessing missing glyphs.