pub struct TextIntrinsic { /* private fields */ }Expand description
Skia-backed intrinsic measurer for Text (audit #10: despite the name
this module’s doc header suggests, this uses skia_safe::Font:: measure_str via engine::renderer::text’s fallback-aware helpers — the
same primitives Text::paint draws with — not engine::text::cosmic,
which has no callers on the real render path at all; see that module’s
doc comment).
Implementations§
Source§impl TextIntrinsic
impl TextIntrinsic
Sourcepub fn from_text(text: &Text) -> Self
pub fn from_text(text: &Text) -> Self
M1: white-space: nowrap|pre disables wrapping — the geometry
validator’s unwrappable_text_overflow/ContentOverflowsBox checks
(crates/rustmotion/src/cli/commands/geometry.rs) already branch on
exactly this pair of variants and re-measure via this same
TextIntrinsic, so the wrap decision here must match theirs exactly
or the validator’s assumption about what the renderer produces is
false.
Sourcepub fn with_autofit(self, on: bool) -> Self
pub fn with_autofit(self, on: bool) -> Self
Opt this instance into text-autofit. Deliberately a separate,
explicit step rather than something from_parts/from_parts_with_wrap
read off style themselves: those two constructors are shared by
every atomic/synthetic-style caller in this file (Caption, Kbd,
Badge, Counter) whose painters have no idea text-autofit
exists — if the flag leaked in through the shared style, measure()
would shrink the reserved box for one of those while the painter
went on drawing at the full requested size, which is exactly the
measure-vs-paint divergence this feature exists to prevent, not
reintroduce elsewhere. Only Self::from_text and
GradientTextIntrinsic::from_gradient_text call this, matching the
two painters (Text, GradientText) that actually implement it.
Sourcepub fn from_parts(
content: &str,
style: &CssStyle,
max_width: Option<f32>,
) -> Self
pub fn from_parts( content: &str, style: &CssStyle, max_width: Option<f32>, ) -> Self
Generic constructor shared by GradientText/Caption intrinsics,
whose painters don’t (yet) implement white-space: nowrap — kept
wrap:true unconditionally so their measured size still matches what
those painters actually draw.
Trait Implementations§
Source§impl IntrinsicMeasure for TextIntrinsic
impl IntrinsicMeasure for TextIntrinsic
Auto Trait Implementations§
impl Freeze for TextIntrinsic
impl RefUnwindSafe for TextIntrinsic
impl Send for TextIntrinsic
impl Sync for TextIntrinsic
impl Unpin for TextIntrinsic
impl UnsafeUnpin for TextIntrinsic
impl UnwindSafe for TextIntrinsic
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
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