pub struct Paragraph { /* private fields */ }Expand description
Shaped, line-broken and aligned text, ready to draw as GlyphRuns.
Built by TextSystem::paragraph. Changing the width (reflow) re-breaks
the shaped text without shaping it again; changing the text or styles needs a new
paragraph. Iterating runs never allocates, so drawing a paragraph every
frame is allocation-free.
Not yet supported: variable-font axes and synthetic bold/italic (glyphs are drawn from the face’s default instance), color glyphs (emoji draw as coverage masks).
Implementations§
Source§impl Paragraph
impl Paragraph
Sourcepub fn height(&self) -> f32
pub fn height(&self) -> f32
Height of all lines, in pixels: the bottom of the last line box.
Taken from the (pixel-snapped) line boxes rather than parley’s unsnapped total, so stacking paragraphs by height never drifts from where their lines are drawn.
Sourcepub fn max_width(&self) -> Option<f32>
pub fn max_width(&self) -> Option<f32>
The width lines wrap at; None if they only break at newlines.
Sourcepub fn glyph_count(&self) -> usize
pub fn glyph_count(&self) -> usize
Glyphs to draw, in all runs.
Sourcepub fn runs(&self) -> impl ExactSizeIterator<Item = GlyphRun<'_>> + '_
pub fn runs(&self) -> impl ExactSizeIterator<Item = GlyphRun<'_>> + '_
The glyph runs to draw, positioned relative to the paragraph’s top-left corner.
Sourcepub fn reflow(&mut self, max_width: Option<f32>) -> Result<(), ParagraphError>
pub fn reflow(&mut self, max_width: Option<f32>) -> Result<(), ParagraphError>
Re-breaks and re-aligns the lines for a new max_width (None: no wrapping),
without shaping again.
§Errors
ParagraphError::InvalidWidth if max_width is negative or not finite.