ui::TextStyle¶
Header: winui/render/Text.hpp.
Everything a Renderer and TextMeasurer need to know about how a run of text looks: font, size, weight, alignment inside its box, wrapping, decorations and spacing.
A plain aggregate, filled in with designated initializers. Controls normally take their style from the theme's type ramp (see TextRole); passing one explicitly (TextControl::set_text_style(), ui::Text::style) pins it. Sizes are in DIPs.
Example:
const ui::TextStyle heading{
.font_size = 20.0f,
.horizontal = ui::TextAlign::Leading,
.font_family = "Segoe UI Variable",
.weight = ui::FontWeight::SemiBold,
.wrapping = ui::TextWrapping::WrapWholeWords,
};
auto label = std::make_unique<ui::TextControl>("Account");
label->set_text_style(heading); // wins over the theme's role ramp from now on
// Or in a spec:
ui::Text{.text = "Account", .text_style = heading};
font_size¶
Font size in DIPs (not points). Default 14.
horizontal¶
Horizontal placement inside the drawing box; Center by default.
vertical¶
Vertical placement inside the drawing box; Center by default.
font_family¶
Font family name, looked up among the installed fonts.
weight¶
Font weight.
italic¶
Italic face.
line_height¶
Puts every line in a line box of this height in DIPs, whatever the font's natural metrics, as the Metro theme does (20 DIPs for body text, 40 for the 56px header). 0, the default, uses the font's natural line height.
effect¶
Defaults to no effect (a single plain pass); see TextEffect.
wrapping¶
NoWrap (the default) keeps every run on one line, whatever box it is drawn into. A wrapping style is measured with TextMeasurer::measure_wrapped() against the width it will be drawn in, and a renderer breaks its lines at that box's width.
underline¶
A line under the run, at the font's own underline position and thickness. Never changes the measured size.
strikethrough¶
A line through the run, likewise.
character_spacing¶
Extra room after every character, in thousandths of an em (200 at 24px adds 4.8 DIPs a character). Negative values tighten. It is part of the run's advance, so it widens the measured size, the last character's included.
character_spacing_dips¶
character_spacing converted to DIPs per character at this style's font_size.