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() -> Self
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.