Skip to main content

ParagraphStyle

Struct ParagraphStyle 

Source
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

Source

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.

Source

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

Source

pub fn new(text: impl Into<Arc<str>>) -> Self

Creates a paragraph of one inheriting span with size 24 and line height 1.3.

Source

pub fn rich(spans: impl IntoIterator<Item = TextSpan>) -> Self

Creates rich spans, whose unset styles inherit paragraph defaults.

Source

pub fn family(self, family: impl Into<Arc<str>>) -> Self

Selects an explicit family; empty uses the library’s generic default.

Source

pub fn size(self, size: f64) -> Self

Sets finite logical size in (0,4096].

Source

pub fn weight(self, weight: FontWeight) -> Self

Selects OpenType weight; variable weight participates in glyph identity.

Source

pub fn line_height(self, height: f64) -> Self

Sets a positive relative line-height multiplier.

Source

pub fn letter_spacing(self, spacing: f64) -> Self

Sets logical tracking, converted to em internally for shaping.

Source

pub fn max_width(self, width: f64) -> Self

Wraps to finite positive logical width.

Source

pub fn alignment(self, alignment: TextAlignment) -> Self

Selects bidirectional-aware paragraph alignment.

Source

pub fn fonts(self, fonts: &FontLibrary) -> Self

Binds an explicit font snapshot, overriding a DrawContext environment.

Trait Implementations§

Source§

impl Clone for ParagraphStyle

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ParagraphStyle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.