Skip to main content

Module typography

Module typography 

Expand description

The semantic type system.

Apps say what a piece of text is — a TextRole — and the theme decides its face, size, weight and leading. Every role size is a ratio of one body size, so a theme author retunes the whole scale with Typography::with_base_size and the accessibility text scale grows every role at once. Typography::style (and its shorthand crate::theme::Theme::text) returns a style whose size already includes the theme’s UI and text scale (TextScaling::Resolved), so the renderer paints it exactly once at that size.

Structs§

FontFamily
A named font family, wrapped so consumers can extend with fallbacks/weights later without breaking token consumers.
TypeScale
The one size every role derives from: the body size, already multiplied by the theme’s UI and text scale. Private so nothing outside the toolkit can pick a pixel size; read a role through Typography::style.
Typography
A theme’s type: three families and the scale every role derives from.

Enums§

ReadingFace
A reading face the system ships, chosen by name in a theme’s type role or by a reader in an app that sets long-form text (Books). Each is set through the Reading role’s family, so its optical sizes, features and script fallbacks work like the default’s.
TextRole
What a piece of text is. Pick the role; never a pixel size.
UiFace
A UI face the system ships, chosen by name in a theme’s type role or by the accessibility layer. Reading (ReadingFace) and code keep their own faces.

Constants§

REFERENCE_BODY_PX
The body size, in logical pixels at 1×, that every role is designed against. Role sizes are body × role_px / REFERENCE_BODY_PX, so they land on whole pixels at the stock size.