FontAtlas

Struct FontAtlas 

Source
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

Source

pub fn load_default(gl: &WebGl2RenderingContext) -> Result<Self, Error>

Loads the default embedded font atlas.

Source

pub fn load( gl: &WebGl2RenderingContext, config: FontAtlasData, ) -> Result<Self, Error>

Creates a TextureAtlas from a grid of equal-sized cells

Source

pub fn bind(&self, gl: &WebGl2RenderingContext, texture_unit: u32)

Binds the atlas texture to the specified texture unit

Source

pub fn cell_size(&self) -> (i32, i32)

Source

pub fn underline(&self) -> LineDecoration

Returns the underline configuration

Source

pub fn strikethrough(&self) -> LineDecoration

Returns the strikethrough configuration

Source

pub fn get_symbol(&self, glyph_id: u16) -> Option<Cow<'_, str>>

Returns the symbol for the given glyph ID, if it exists

Source

pub fn get_base_glyph_id(&self, key: &str) -> Option<u16>

Returns the base glyph identifier for the given key

Source

pub fn glyph_tracker(&self) -> &GlyphTracker

Returns a reference to the glyph tracker for accessing missing glyphs.

Trait Implementations§

Source§

impl Debug for FontAtlas

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.