Skip to main content

StaticFontAtlas

Struct StaticFontAtlas 

Source
pub struct StaticFontAtlas { /* private fields */ }
Expand description

A texture atlas containing font glyphs for efficient GL text rendering.

StaticFontAtlas manages a GL 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 GL 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 StaticFontAtlas

Source

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

Creates a TextureAtlas from a grid of equal-sized cells

Trait Implementations§

Source§

impl Atlas for StaticFontAtlas

Source§

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

Returns the base glyph identifier for the given key

Source§

fn underline(&self) -> LineDecoration

Returns the underline configuration

Source§

fn strikethrough(&self) -> LineDecoration

Returns the strikethrough configuration

Source§

fn get_symbol(&self, glyph_id: u16) -> Option<CompactString>

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

Source§

fn recreate_texture(&mut self, gl: &Context) -> Result<(), Error>

Recreates the GPU texture after a context loss.

This method rebuilds the texture from the retained atlas data. All glyph mappings and other CPU-side state are preserved; only the GPU texture handle is recreated.

Source§

fn base_lookup_mask(&self) -> u32

Returns 0x1FFF to support the full glyph encoding from beamterm-atlas.

This 13-bit mask includes the emoji flag (bit 12) so that emoji base IDs can be extracted correctly for symbol lookup and texture coordinate calculation.

Source§

fn get_glyph_id(&self, key: &str, style_bits: u16) -> Option<u16>

Returns the glyph identifier for the given key and style bits
Source§

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

Returns the height of the atlas in pixels.
Source§

fn bind(&self, gl: &Context)

Binds the font atlas texture to the currently active texture unit.
Source§

fn get_ascii_char(&self, glyph_id: u16) -> Option<char>

Returns the ASCII character for the given glyph ID, if it represents an ASCII char. Read more
Source§

fn glyph_tracker(&self) -> &GlyphTracker

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

fn glyph_count(&self) -> u32

Returns the number of glyphs currently in the atlas.
Source§

fn flush(&self, _gl: &Context) -> Result<(), Error>

Flushes any pending glyph data to the GPU texture. Read more
Source§

fn for_each_symbol(&self, f: &mut dyn FnMut(u16, &str))

Iterates over all glyph ID to symbol mappings. Read more
Source§

fn resolve_glyph_slot(&self, key: &str, style_bits: u16) -> Option<GlyphSlot>

Resolves a glyph to its texture slot. Read more
Source§

fn delete(&self, gl: &Context)

Deletes the GPU texture resources associated with this atlas. Read more
Source§

fn update_pixel_ratio( &mut self, _gl: &Context, pixel_ratio: f32, ) -> Result<f32, Error>

Updates the pixel ratio for HiDPI rendering. Read more
Source§

fn cell_scale_for_dpr(&self, pixel_ratio: f32) -> f32

Returns the cell scale factor for layout calculations at the given DPR. Read more
Source§

fn texture_cell_size(&self) -> (i32, i32)

Returns the texture cell size in physical pixels (for fragment shader calculations). Read more
Source§

impl Debug for StaticFontAtlas

Source§

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

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.