Skip to content

ui::TextMetrics

Header: winui/render/Text.hpp.

What a TextMeasurer reports for a run of text: its extent, where its first baseline sits and how many lines it took. Converts to a Size (the extent), so code that only needs the box reads .width and .height or assigns it to a Size.

Example:

const ui::TextStyle   style{.font_size = 14.0f};
const ui::TextMetrics metrics = measurer.measure("Hello", style);
const ui::Size        box     = metrics; // width x height
const float           ascent  = metrics.baseline;

width

float width = 0.0f

The widest line's width, in DIPs.

height

float height = 0.0f

The height of all lines together, in DIPs.

baseline

float baseline = 0.0f

From the top of the box to the first line's baseline, in DIPs.

line_count

int line_count = 1

How many lines the text took; 1 for a single line, empty text included.

size

Size size() const

The extent, width x height.

operator Size

operator Size() const