pub struct ParagraphStyle { /* private fields */ }Expand description
Paragraph description: rich text, base style, width, alignment and optional fonts.
Shaping it yields a ParagraphLayout, the single intermediate
representation behind static drawing, reveal effects and captions. Changing a
shaping parameter gives a new cache; unchanged ones keep sharing the layout.
Implementations§
Source§impl ParagraphStyle
impl ParagraphStyle
Sourcepub fn fit_lines(
&self,
max_lines: usize,
fonts: &FontLibrary,
) -> Result<(Self, bool), ValidationError>
pub fn fit_lines( &self, max_lines: usize, fonts: &FontLibrary, ) -> Result<(Self, bool), ValidationError>
Precomputes a paragraph limited to 1..=512 lines, adding an ellipsis only when truncated. Returns the paragraph and whether source content was removed. Rich styles and extended grapheme boundaries are retained. The supplied font snapshot is frozen on the returned paragraph; no system discovery occurs. Preparation may reshape bounded suffix candidates and is not a frame-loop API.
Sourcepub fn layout(
&self,
fonts: &FontLibrary,
) -> Result<Arc<ParagraphLayout>, ValidationError>
pub fn layout( &self, fonts: &FontLibrary, ) -> Result<Arc<ParagraphLayout>, ValidationError>
Shapes once per paragraph description and font snapshot, returning actual line/ink metrics. Clones and equal descriptions share the result.
Source§impl ParagraphStyle
impl ParagraphStyle
Sourcepub fn new(text: impl Into<Arc<str>>) -> Self
pub fn new(text: impl Into<Arc<str>>) -> Self
Creates a paragraph of one inheriting span with size 24 and line height 1.3.
Sourcepub fn rich(spans: impl IntoIterator<Item = TextSpan>) -> Self
pub fn rich(spans: impl IntoIterator<Item = TextSpan>) -> Self
Creates rich spans, whose unset styles inherit paragraph defaults.
Sourcepub fn family(self, family: impl Into<Arc<str>>) -> Self
pub fn family(self, family: impl Into<Arc<str>>) -> Self
Selects an explicit family; empty uses the library’s generic default.
Sourcepub fn weight(self, weight: FontWeight) -> Self
pub fn weight(self, weight: FontWeight) -> Self
Selects OpenType weight; variable weight participates in glyph identity.
Sourcepub fn line_height(self, height: f64) -> Self
pub fn line_height(self, height: f64) -> Self
Sets a positive relative line-height multiplier.
Sourcepub fn letter_spacing(self, spacing: f64) -> Self
pub fn letter_spacing(self, spacing: f64) -> Self
Sets logical tracking, converted to em internally for shaping.
Sourcepub fn alignment(self, alignment: TextAlignment) -> Self
pub fn alignment(self, alignment: TextAlignment) -> Self
Selects bidirectional-aware paragraph alignment.
Sourcepub fn fonts(self, fonts: &FontLibrary) -> Self
pub fn fonts(self, fonts: &FontLibrary) -> Self
Binds an explicit font snapshot, overriding a DrawContext environment.