pub struct TextSystem { /* private fields */ }Expand description
The shaping and rasterization state of one window. The font database
it shapes against is not in here — that is the session’s
(crate::session::Session), passed in as fs — because a font
registered in one window has to shape in every window of the session.
What is here is coupled to this window’s glyph atlas: the shaped-buffer
cache stamps its positioned glyphs with the atlas stamp they were
packed against, and the frame lists are what TextId indexes.
Implementations§
Source§impl TextSystem
impl TextSystem
pub fn new() -> TextSystem
Sourcepub fn budget(&self) -> usize
pub fn budget(&self) -> usize
The byte budget the cache is evicted to; see
Core::set_text_cache_budget.
Sourcepub fn set_budget(&mut self, bytes: usize)
pub fn set_budget(&mut self, bytes: usize)
Sets the budget. Takes effect at the next frame’s start, where eviction runs; nothing is evicted here.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
How many shaped texts the cache holds (a long line’s chunks each count; the line itself does not).
Sourcepub fn long_lines(&self) -> usize
pub fn long_lines(&self) -> usize
How many long lines are held.
pub fn is_empty(&self) -> bool
Sourcepub fn add(
&mut self,
content: &str,
style: &TextStyle,
res: &Resources,
fs: &mut FontSystem,
) -> TextId
pub fn add( &mut self, content: &str, style: &TextStyle, res: &Resources, fs: &mut FontSystem, ) -> TextId
Registers a text for this frame, shaping (or reusing) its buffer.
Sourcepub fn measure(
&mut self,
content: &str,
style: &TextStyle,
res: &Resources,
fs: &mut FontSystem,
max_w: Option<f32>,
) -> TextMetrics
pub fn measure( &mut self, content: &str, style: &TextStyle, res: &Resources, fs: &mut FontSystem, max_w: Option<f32>, ) -> TextMetrics
Measures content in style without adding a node: its unwrapped
size, or with max_w (logical px) its size once wrapped to that
width. The answer is what layout would give a text node with the
same content and style at the current scale, wrap / max_lines /
ellipsis included.
Sourcepub fn measure_rich(
&mut self,
spans: &[Span<'_>],
base: &TextStyle,
res: &Resources,
fs: &mut FontSystem,
max_w: Option<f32>,
) -> TextMetrics
pub fn measure_rich( &mut self, spans: &[Span<'_>], base: &TextStyle, res: &Resources, fs: &mut FontSystem, max_w: Option<f32>, ) -> TextMetrics
measure for a rich-text paragraph.
Sourcepub fn add_rich(
&mut self,
spans: &[Span<'_>],
base: &TextStyle,
res: &Resources,
fs: &mut FontSystem,
) -> TextId
pub fn add_rich( &mut self, spans: &[Span<'_>], base: &TextStyle, res: &Resources, fs: &mut FontSystem, ) -> TextId
Registers a rich-text paragraph for this frame. Spans shape as one flow, so wrapping crosses style boundaries correctly; past the long-line threshold the flow is chunked like a plain line’s.
Trait Implementations§
Source§impl Default for TextSystem
impl Default for TextSystem
Source§fn default() -> TextSystem
fn default() -> TextSystem
Auto Trait Implementations§
impl Freeze for TextSystem
impl RefUnwindSafe for TextSystem
impl Send for TextSystem
impl Sync for TextSystem
impl Unpin for TextSystem
impl UnsafeUnpin for TextSystem
impl UnwindSafe for TextSystem
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
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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.