Skip to main content

FontAtlas

Struct FontAtlas 

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

Type-erased wrapper around any Atlas implementation.

Implementations§

Source§

impl FontAtlas

Source

pub fn new(inner: impl Atlas + 'static) -> Self

Wraps an atlas implementation in a type-erased container.

Source

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

Returns the styled glyph ID for the given symbol.

Source

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

Returns the unstyled base glyph ID for the given symbol.

Source

pub fn cell_size(&self) -> CellSize

Returns the cell dimensions used for grid layout.

Source

pub fn bind(&self, gl: &Context)

Binds the atlas texture for rendering.

Source

pub fn underline(&self) -> LineDecoration

Returns underline position and thickness metadata.

Source

pub fn strikethrough(&self) -> LineDecoration

Returns strikethrough position and thickness metadata.

Source

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

Returns the symbol string for the given glyph ID.

Source

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

Returns the ASCII character for the given glyph ID, if applicable.

Source

pub fn glyph_tracker(&self) -> &GlyphTracker

Returns a reference to the glyph usage tracker.

Source

pub fn glyph_count(&self) -> u32

Returns the total number of allocated glyphs.

Source

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

Recreates the GPU texture after a context loss.

§Errors

Returns an error if GPU texture creation fails.

Source

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

Iterates over all glyph ID to symbol mappings.

Source

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

Resolves a symbol to its glyph slot classification.

Source

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

Flushes pending glyph data to the GPU texture.

§Errors

Returns an error if texture upload fails.

Source

pub fn delete(&self, gl: &Context)

Deletes the GPU texture resources associated with this atlas.

Source

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

Updates the pixel ratio for HiDPI rendering.

Returns the effective pixel ratio to use for viewport scaling.

§Errors

Returns an error if GPU texture recreation fails during reinitialization.

Source

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

Returns the cell scale factor for layout calculations.

Source

pub fn texture_cell_size(&self) -> CellSize

Returns the texture cell size in physical pixels.

Trait Implementations§

Source§

impl Debug for FontAtlas

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<A: Atlas + 'static> From<A> for FontAtlas

Source§

fn from(atlas: A) -> Self

Converts to this type from the input type.

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.