Struct three_d_text_builder::GlyphCache
source · 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
impl GlyphCache
sourcepub fn fill_ratio(&self) -> f32
pub fn fill_ratio(&self) -> f32
Returns how much of the CPU texture’s area is currently used by glyphs
sourcepub fn is_exhausted(&self) -> bool
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
sourcepub fn material(&self) -> Option<&TextMaterial>
pub fn material(&self) -> Option<&TextMaterial>
Returns a reference to the cache’s currently uploaded GPU material