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
impl Text
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 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.
Sourcepub fn layout(
&self,
fonts: &FontLibrary,
) -> Result<Arc<ParagraphLayout>, ValidationError>
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
impl Text
Sourcepub fn try_animate_parts_at(
&self,
context: &SceneContext<'_>,
delay: Duration,
style: impl Fn(&TextPart) -> PartStyle,
) -> Result<Node, ValidationError>
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
impl Text
Sourcepub fn from_font(
text: &str,
font: &FontFace,
size: f64,
paint: impl Into<Paint>,
) -> Result<Self, ValidationError>
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.
Sourcepub fn new(text: impl Into<Arc<str>>) -> Self
pub fn new(text: impl Into<Arc<str>>) -> Self
Creates a paragraph with size 24, line height 1.3 and white fill.
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 fill(self, paint: impl Into<Paint>) -> Self
pub fn fill(self, paint: impl Into<Paint>) -> Self
Sets paint without invalidating shaped geometry.
Sourcepub fn stroke(self, width: f64, paint: impl Into<Paint>) -> Self
pub fn stroke(self, width: f64, paint: impl Into<Paint>) -> Self
Adds stroke after filling; existing bounded stroke rules apply.
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.
Sourcepub fn split(self, split: TextSplit) -> Self
pub fn split(self, split: TextSplit) -> Self
Selects grapheme, word-boundary or wrapped-line parts.
Sourcepub fn visible_parts(self, count: usize) -> Self
pub fn visible_parts(self, count: usize) -> Self
Keeps original layout while drawing only the first logical parts.
Sourcepub fn write(self, progress: f64) -> Self
pub fn write(self, progress: f64) -> Self
Defers vector handwriting to compilation with the current font environment.
Sourcepub fn animate_parts(
self,
delay: Duration,
style: impl Fn(&TextPart) -> PartStyle + Send + Sync + 'static,
) -> Self
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.
Sourcepub fn write_with_context(
&self,
progress: f64,
context: &DrawContext,
) -> Result<Node, ValidationError>
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.
Sourcepub fn vector_tree(
&self,
context: &DrawContext,
) -> Result<Arc<VectorTree>, ValidationError>
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 Drawable for Text
impl Drawable for Text
Source§fn resolve_node(
&self,
context: &DrawContext,
) -> Result<Option<Node>, ValidationError>
fn resolve_node( &self, context: &DrawContext, ) -> Result<Option<Node>, ValidationError>
Source§fn try_bounds(&self, context: &DrawContext) -> Result<Rect, ValidationError>
fn try_bounds(&self, context: &DrawContext) -> Result<Rect, ValidationError>
Source§fn bounds(&self, context: &DrawContext) -> Rect
fn bounds(&self, context: &DrawContext) -> Rect
Source§fn baseline(&self, context: &DrawContext) -> Option<f64>
fn baseline(&self, context: &DrawContext) -> Option<f64>
Source§fn draw(
&self,
context: &DrawContext,
canvas: &mut Canvas<'_>,
) -> Result<(), ValidationError>
fn draw( &self, context: &DrawContext, canvas: &mut Canvas<'_>, ) -> Result<(), ValidationError>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Output> IntoSceneOutput for Output
impl<Output> IntoSceneOutput for Output
Source§impl<Value> NodeModifiers for Value
impl<Value> NodeModifiers for Value
Source§fn layered_shadow(self, color: Color, radius: f64, offset: Vector2) -> Node
fn layered_shadow(self, color: Color, radius: f64, offset: Vector2) -> Node
Source§fn elevated(self, elevation: Elevation) -> Node
fn elevated(self, elevation: Elevation) -> Node
Elevation.