Skip to main content

TextIntrinsic

Struct TextIntrinsic 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn from_parts_with_wrap( content: &str, style: &CssStyle, max_width: Option<f32>, wrap: bool, ) -> Self

Build with an explicit wrap override (used by atomic components like counter, kbd, badge that never wrap).

Trait Implementations§

Source§

impl IntrinsicMeasure for TextIntrinsic

Source§

fn measure( &self, known: (Option<f32>, Option<f32>), available: (AvailableSpace, AvailableSpace), ) -> (f32, f32)

Measure intrinsic size given the available width/height. Either side may be None if unconstrained (e.g. min-content pass).

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<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.