Skip to main content

Module intrinsic

Module intrinsic 

Source
Expand description

Intrinsic measurers for components whose box size depends on content.

Uses the same Skia metrics that the painter uses, so the box reserved by taffy matches the pixels actually drawn — measure-vs-paint mismatches would otherwise cause text to wrap onto an extra line at paint time and overflow into the next sibling.

Structs§

BadgeIntrinsic
Intrinsic measurer for Badge — measures the label text plus icon, gap, and the size-derived horizontal/vertical padding.
CaptionIntrinsic
Intrinsic measurer for Caption. Concatenates the words with single spaces and measures the result like a regular text run.
CodeblockIntrinsic
Intrinsic measurer for Codeblock.
CounterIntrinsic
Intrinsic measurer for Counter — reserves space for the largest absolute value the counter will display so layout never reflows during animation.
GradientTextIntrinsic
Cosmic-text–backed intrinsic measurer for GradientText — same content model as Text (a single string + style); the gradient is purely a paint-time concern and doesn’t change box dimensions.
KbdIntrinsic
Intrinsic measurer for Kbd — measures the key text plus the legacy keyboard-cap padding (h ≈ font_size × 0.7, v ≈ font_size × 0.4) and enforces a min-width of font_size × 1.8.
NumberWheelIntrinsic
Intrinsic measurer for crate::number_wheel::NumberWheel.
RichTextIntrinsic
Intrinsic measurer for RichText.
TableIntrinsic
Intrinsic measurer for Table.
TerminalIntrinsic
Intrinsic measurer for Terminal.
TextIntrinsic
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).

Functions§

font_size_ctx
LengthContext for resolving font-size (and, through CssStyle::typography_px_ctx, letter-spacing/line-height derived from it) against a real, per-frame viewport. Use from Painter:: paint_content and friends, which have a real PaintCtx (video_width/ video_height) on hand.
measure_time_font_size_ctx
Same as font_size_ctx, for the Intrinsic measurers in this module: they run at box_builder/geometry construction time, before layout, so there is no real per-frame viewport to hand (see the pre-existing note on TextIntrinsic::from_parts, which has the same limitation for letter-spacing/line-height). Falls back to the engine-wide default 1920×1080 (same as LengthContext::default()) so rem — which does not depend on the viewport at all — still resolves exactly, and vw/vh get a reasonable non-zero approximation instead of silently dropping to 0. This can diverge from what Painter::paint_content resolves via font_size_ctx for vw/vh specifically, on videos that aren’t 1920×1080 — closing that fully needs the real VideoConfig threaded through box_builder.rs/geometry.rs, both outside this workstream.
resolve_text_autofit
text-autofit’s shared shrink resolution — the single computation TextIntrinsic::measure and Text/GradientText’s painters all call with identical inputs, so the resolved size can never disagree between the box taffy reserves and the pixels actually painted into it (see CssStyle::text_autofit’s doc comment — this exact class of bug is what this workstream exists to close, not reopen).