Skip to main content

Text

Struct Text 

Source
pub struct Text { /* private fields */ }
Expand description

multi-line Unicode text; cosmic-text is the sole paragraph shaper, while unhinted skrifa outlines enter the ordinary shared fill pipeline.

Implementations§

Source§

impl Text

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 text and whether source content was removed. Rich styles and extended grapheme boundaries are retained. The supplied font snapshot is frozen on the returned text; 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 text-style/font snapshot, returning actual line/ink metrics.

Source§

impl Text

Source

pub fn try_animate_parts_at( &self, context: &SceneContext<'_>, delay: Duration, style: impl Fn(&TextPart) -> PartStyle, ) -> Result<Node, ValidationError>

Evaluates part styles synchronously at explicit scene-local signed time, without reshaping for animation. Source bounds and line wrapping stay fixed; returned node bounds also include transformed animation ink. Measured paragraph baseline is retained for horizontal Row alignment.

Source§

impl Text

Source

pub fn from_font( text: &str, font: &FontFace, size: f64, paint: impl Into<Paint>, ) -> Result<Self, ValidationError>

Builds and validates text using one explicit immutable font face.

Source

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

Creates a paragraph with size 24, line height 1.3 and white fill.

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 fill(self, paint: impl Into<Paint>) -> Self

Sets paint without invalidating shaped geometry.

Source

pub fn stroke(self, width: f64, paint: impl Into<Paint>) -> Self

Adds stroke after filling; existing bounded stroke rules apply.

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.

Source

pub fn split(self, split: TextSplit) -> Self

Selects grapheme, word-boundary or wrapped-line parts.

Source

pub fn visible_parts(self, count: usize) -> Self

Keeps original layout while drawing only the first logical parts.

Source

pub fn write(self, progress: f64) -> Self

Defers vector handwriting to compilation with the current font environment.

Source

pub fn animate_parts( self, delay: Duration, style: impl Fn(&TextPart) -> PartStyle + Send + Sync + 'static, ) -> Self

Defers per-part style evaluation to scene-local drawing time.

Source

pub fn write_with_context( &self, progress: f64, context: &DrawContext, ) -> Result<Node, ValidationError>

Applies the common vector handwriting effect with default contour/fill handoff. Bind fonts on this Text or supply them in the DrawContext.

Source

pub fn vector_tree( &self, context: &DrawContext, ) -> Result<Arc<VectorTree>, ValidationError>

Exports original shared glyph curves, color layers, bitmap strikes and source ranges into the common vector model. No second shaping pass occurs.

Trait Implementations§

Source§

impl Clone for Text

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 Text

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drawable for Text

Source§

fn resolve_node( &self, context: &DrawContext, ) -> Result<Option<Node>, ValidationError>

Resolves deferred content to ordinary nodes at the current drawing time.
Source§

fn try_bounds(&self, context: &DrawContext) -> Result<Rect, ValidationError>

Checked bounds for fallible content such as explicit-font paragraphs. Existing geometry implementations may keep the infallible bounds method.
Source§

fn bounds(&self, context: &DrawContext) -> Rect

Local layout/ink bounds before node placement.
Source§

fn baseline(&self, context: &DrawContext) -> Option<f64>

Real horizontal text baseline in local coordinates; geometry has none.
Source§

fn draw( &self, context: &DrawContext, canvas: &mut Canvas<'_>, ) -> Result<(), ValidationError>

Emits local commands; validation errors propagate without partial output.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Text

§

impl !UnwindSafe for Text

§

impl Forget for Text

§

impl Freeze for Text

§

impl Send for Text

§

impl Sync for Text

§

impl Unpin for Text

§

impl UnsafeUnpin for Text

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<Output> IntoSceneOutput for Output
where Output: Into<Node>,

Source§

fn into_scene_output(self) -> Result<Node, Error>

Preserves the original failure category and source.
Source§

impl<Value> NodeModifiers for Value
where Value: Into<Node>,

Source§

fn layered_shadow(self, color: Color, radius: f64, offset: Vector2) -> Node

Layers three soft silhouettes behind a single untouched source snapshot.
Source§

fn elevated(self, elevation: Elevation) -> Node

Layers contact, key and ambient soft shadows that scale with an Elevation.
Source§

fn gate_weave(self, seed: u64, frame: u64, amount: f64) -> Node

Repeatable physical gate drift, keyed only by an explicit frame and seed.
Source§

fn next_to(self, reference: &Node, side: Side, gap: f64) -> Node

Places content next to the reference during compile-time layout.
Source§

fn align_to(self, reference: &Node, edge: Side) -> Node

Aligns an edge with a compile-time measured reference snapshot.
Source§

fn at(self, position: impl Into<Point>) -> Node

Places the selected pivot at a parent-space point, before translation.
Source§

fn translate(self, horizontal: f64, vertical: f64) -> Node

Adds parent-space translation, after scale and rotation.
Source§

fn rotate(self, radians: f64) -> Node

Adds clockwise radians about the pivot, after scale and before translation.
Source§

fn scale(self, factor: f64) -> Node

Multiplies both scale factors; negative factors reflect and zero collapses.
Source§

fn scale_xy(self, horizontal: f64, vertical: f64) -> Node

Multiplies per-axis scale factors about the pivot.
Source§

fn pivot(self, pivot: Pivot) -> Node

Replaces the local-space pivot; defaults to the layout-bounds center.
Source§

fn opacity(self, opacity: f64) -> Node

Replaces subtree opacity; invalid values are reported during conversion.
Source§

fn blend_mode(self, mode: BlendMode) -> Node

Blends the completed subtree once against its immediate parent backdrop. Read more
Source§

fn filter(self, filter: Filter) -> Node

Appends a source-only filter, preserving declaration order. Read more
Source§

fn clip(self, shape: impl Into<ShapeClip>) -> Node

Replaces the subtree’s local path-coverage clip without changing layout. Read more
Source§

fn clip_with(self, shape: impl Into<ShapeClip>, mode: ClipMode) -> Node

Clips with explicit coverage multiplication or geometric intersection.
Source§

fn mask(self, mask: impl Into<Node>, mode: MaskMode) -> Node

Replaces the local geometric rectangle clip without changing layout. Read more
Source§

fn z_index(self, index: i32) -> Node

Replaces sibling-local stacking order; ties retain insertion order.
Source§

fn visible(self, visible: bool) -> Node

Removes the snapshot entirely when false, rather than evaluating it hidden.
Source§

fn named(self, name: &str) -> Node

Attaches a diagnostic name without changing artwork or draw order.
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.