pub struct TextSubsystem {
pub engine: TextEngine,
pub glyph_cache: LruCache<u64, (Rect, f32, f32, f32, f32)>,
pub shaped_cache: LruCache<(String, u32), Arc<ShapedText>>,
pub atlas_size: u32,
}Expand description
Group of caches and engines used for text rendering.
Fields§
§engine: TextEngineThe Runic text shaping engine. Default-constructible; the engine itself is stateless across threads.
glyph_cache: LruCache<u64, (Rect, f32, f32, f32, f32)>LRU cache mapping glyph hash -> (uv_rect, w, h, x_off, y_off). Capacity is configurable via RendererConfig.
shaped_cache: LruCache<(String, u32), Arc<ShapedText>>Shaped text cache keyed by (text, font_size). Bounded so it
survives across frames without growing without limit.
Stores Arc
atlas_size: u32Size of each glyph atlas in pixels (width and height).
Implementations§
Source§impl TextSubsystem
impl TextSubsystem
Sourcepub fn forge(glyph_cache_capacity: NonZeroUsize) -> Self
pub fn forge(glyph_cache_capacity: NonZeroUsize) -> Self
Create a text subsystem with the given LRU capacity for the glyph cache and default 4096x4096 atlas size.
Sourcepub fn with_atlas_size(
glyph_cache_capacity: NonZeroUsize,
atlas_size: u32,
) -> Self
pub fn with_atlas_size( glyph_cache_capacity: NonZeroUsize, atlas_size: u32, ) -> Self
Create a text subsystem with a custom atlas size (in pixels).
Sourcepub fn atlas_size(&self) -> u32
pub fn atlas_size(&self) -> u32
Return the configured atlas size in pixels.
Sourcepub fn clear_caches(&mut self)
pub fn clear_caches(&mut self)
Clear both caches. Called on theme change.
Auto Trait Implementations§
impl !RefUnwindSafe for TextSubsystem
impl !UnwindSafe for TextSubsystem
impl Freeze for TextSubsystem
impl Send for TextSubsystem
impl Sync for TextSubsystem
impl Unpin for TextSubsystem
impl UnsafeUnpin for TextSubsystem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more