pub struct RichText {
pub spans: Vec<RichTextSpan>,
pub max_width: Option<f32>,
pub timing: TimingConfig,
pub style: CssStyle,
pub timeline: Vec<TimelineStep>,
pub stagger: Option<f32>,
}Expand description
Rich text component: renders multiple styled spans on the same line(s).
Fields§
§spans: Vec<RichTextSpan>§max_width: Option<f32>§timing: TimingConfig§style: CssStyle§timeline: Vec<TimelineStep>§stagger: Option<f32>Implementations§
Source§impl RichText
impl RichText
Sourcepub fn compute_layout(
spans: &[RichTextSpan],
style: &CssStyle,
viewport_width: f32,
viewport_height: f32,
wrap_width: Option<f32>,
visible_chars_progress: f32,
) -> RichTextLayout
pub fn compute_layout( spans: &[RichTextSpan], style: &CssStyle, viewport_width: f32, viewport_height: f32, wrap_width: Option<f32>, visible_chars_progress: f32, ) -> RichTextLayout
Word-wrap spans at wrap_width (None = unconstrained/natural
width). visible_chars_progress >= 0.0 truncates the content for the
typewriter effect (same char-count semantics as text); -1.0 shows
everything (used for intrinsic/natural-size measurement, which must
not shrink as the typewriter plays out — layout space is reserved for
the full content up front).
Unlike the original implementation (which only ever broke a line at a
span boundary — a single long span never wrapped internally), this
tokenizes every span’s text into words and packs them greedily across
span boundaries, so a long single span wraps like any other text.
Whitespace runs collapse to a single rendered space (CSS
white-space: normal semantics, matching text’s default wrap
behaviour); the exact inter-word spacing of source whitespace is not
preserved, matching how wrap_text_with_fallback already treats
plain text content.
viewport_width/viewport_height resolve rem/vw/vh on
style.font-size (lot B, wave S — this used to go through the
context-free font_size_px_or, which silently resolved those units
to 0px). Callers with no real per-frame viewport (intrinsic
measurement, which runs before layout) should pass a stand-in — see
intrinsic::measure_time_font_size_ctx’s doc comment for why 0px is
worse than an approximation.
Trait Implementations§
Source§impl Animatable for RichText
impl Animatable for RichText
fn animation_effects(&self) -> &[AnimationEffect]
Source§fn timeline_steps(&self) -> &[TimelineStep]
fn timeline_steps(&self) -> &[TimelineStep]
timeline field): each step’s animations are
resolved with delay += step.at. Empty by default.Source§impl<'de> Deserialize<'de> for RichText
impl<'de> Deserialize<'de> for RichText
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for RichText
impl JsonSchema for RichText
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§impl Painter for RichText
impl Painter for RichText
Source§fn paint_content(
&self,
canvas: &Canvas,
layout: &BoxLayout,
props: &AnimatedProperties,
ctx: &PaintCtx,
)
fn paint_content( &self, canvas: &Canvas, layout: &BoxLayout, props: &AnimatedProperties, ctx: &PaintCtx, )
overflow: hidden was set. Generic decorations (bg, border,
shadow) are already painted by the engine. Read moreSource§fn intrinsic_size(
&self,
_available: AvailableSize,
_ctx: &MeasureCtx,
) -> Option<(f32, f32)>
fn intrinsic_size( &self, _available: AvailableSize, _ctx: &MeasureCtx, ) -> Option<(f32, f32)>
text, image,
codeblock. Return None to let taffy compute the size from the
CSS style alone. available mirrors taffy’s AvailableSpace.Auto Trait Implementations§
impl Freeze for RichText
impl RefUnwindSafe for RichText
impl Send for RichText
impl Sync for RichText
impl Unpin for RichText
impl UnsafeUnpin for RichText
impl UnwindSafe for RichText
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<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more