pub struct GlyphCache { /* private fields */ }
Expand description

Rasterizes and caches glyphs for a specific font / size combination.

§Implementation

Glyphs get rasterized on demand when first encountered and are packed into a CPU backed atlas texture, when the atlas can no longer fit any additional glyphs its size doubles until it reaches the maximum allowed size.

Once the maximum atlas size has been reached, no further glyphs will get rasterized any any characters that require them will be skipped when building the meshes.

When an atlas gets updated with new glyphs, its GPU texture is uploaded to the GPU as a new material for use with the text meshes.

Note: Font sizes are rounded to the first decimal place.

Note: Glyphs get only rasterized once, but may get copied multiple times into the backing CPU texture in case their position in the atlas changes.

Implementations§

source§

impl GlyphCache

source

pub fn is_empty(&self) -> bool

Returns true in case there are currently no glyphs in the cache

source

pub fn len(&self) -> usize

Returnss the number of rasterized glyphs in the cache

source

pub fn size(&self) -> (u32, u32)

Returns the size of the CPU texture in use by the cache

source

pub fn fill_ratio(&self) -> f32

Returns how much of the CPU texture’s area is currently used by glyphs

source

pub fn is_exhausted(&self) -> bool

Returns true when no further glyphs can be fit into the cache and the maximum texture size as allowed by TextBuilderSettings has already been reached

source

pub fn material(&self) -> Option<&TextMaterial>

Returns a reference to the cache’s currently uploaded GPU material

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>,

§

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>,

§

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.