Skip to main content

TextMeasure

Trait TextMeasure 

Source
pub trait TextMeasure {
    // Required methods
    fn intrinsic(&mut self, id: TextId) -> Size;
    fn wrapped(&mut self, id: TextId, max_w: f32) -> Size;

    // Provided methods
    fn min_content(&mut self, _id: TextId) -> f32 { ... }
    fn edit_intrinsic(&mut self, _key: Key) -> Size { ... }
    fn edit_wrapped(&mut self, _key: Key, _max_w: f32) -> Size { ... }
    fn baseline(&mut self, _id: TextId) -> f32 { ... }
    fn edit_baseline(&mut self, _key: Key) -> f32 { ... }
    fn image_size(&mut self, _id: ImageId) -> Size { ... }
    fn cells_size(&mut self, _id: CellsId) -> Size { ... }
}
Expand description

What the solver asks about text, editors, images and cell grids: the sizes it cannot compute from specs alone. The core implements it over its text system; a test may implement it with fixed numbers.

Required Methods§

Source

fn intrinsic(&mut self, id: TextId) -> Size

Unwrapped preferred size.

Source

fn wrapped(&mut self, id: TextId, max_w: f32) -> Size

Size when wrapped to max_w logical pixels.

Provided Methods§

Source

fn min_content(&mut self, _id: TextId) -> f32

The widest stretch of the text no break falls inside, logical px — CSS’s min-content: the longest word, a whole unwrapped line. Asked only on a frame with a share of the room; 0, the default, is a text that rewraps to any width.

Source

fn edit_intrinsic(&mut self, _key: Key) -> Size

Unwrapped content size of an editable text node.

Source

fn edit_wrapped(&mut self, _key: Key, _max_w: f32) -> Size

Content size of an editable text node wrapped to max_w.

Source

fn baseline(&mut self, _id: TextId) -> f32

The first line’s baseline of a text last wrapped by wrapped, logical px below its top: what crossAlign: baseline lines up. Asked only on a frame with a baseline row. NaN = not known, and the text aligns by its bottom edge.

Source

fn edit_baseline(&mut self, _key: Key) -> f32

An editor’s first baseline, below the top of its text (its box’s padding is added by the caller). NaN = not known.

Source

fn image_size(&mut self, _id: ImageId) -> Size

Pixel dimensions of a registered image (ZERO when unknown).

Source

fn cells_size(&mut self, _id: CellsId) -> Size

The laid-out size of a cell grid (rows × cols cells).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§