guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
guillaume::components::Typography Class Reference

Which typescale role a text uses (BodyMedium, TitleLarge, ...) and an optional explicit size. More...

#include <headers/guillaume/components/typography.hpp>

Inheritance diagram for guillaume::components::Typography:
Collaboration diagram for guillaume::components::Typography:

Public Member Functions

 Typography (void)=default
 Default constructor.
 ~Typography (void)=default
 Default destructor.
theme::TypeRole getRole (void) const
 Get the typescale role.
Typography & setRole (theme::TypeRole role)
 Set the typescale role.
std::optional< float > getFontSize (void) const
 Get the explicit font size.
Typography & setFontSize (std::optional< float > fontSize)
 Override the font size of the role, or clear the override.
Public Member Functions inherited from guillaume::ecs::Component
bool hasChanged (void) const
 Tell whether a value of the component changed since the flags were last reset (the end of the previous frame).
void setHasChanged (bool hasChanged)
 Raise or lower the changed flag.
 Component (void)=default
 Create a component that is not marked as changed.
virtual ~Component (void)=default
 Virtual destructor, so components can be destroyed through the base class.

Detailed Description

Which typescale role a text uses (BodyMedium, TitleLarge, ...) and an optional explicit size.

entities::Text writes it. systems::Typography reads it every frame in the Measure phase, resolves the role against the active theme and writes the font size, weight, line height and letter spacing into the entity's components::Text, so a theme change restyles existing texts.

registry.getComponent<components::Typography>(id).setRole(
Which typescale role a text uses (BodyMedium, TitleLarge, ...) and an optional explicit size.
Typography & setRole(theme::TypeRole role)
Set the typescale role.
@ TitleLarge
22 / 28, regular.
Definition typescale.hpp:54
Note
On an entity that has this component, metrics set directly on components::Text are replaced on the next frame. Change the role or the size override here.
See also
systems::Typography, components::Text, theme::TypeRole

Definition at line 53 of file typography.hpp.

Member Function Documentation

◆ getFontSize()

std::optional< float > guillaume::components::Typography::getFontSize ( void ) const

Get the explicit font size.

Returns
The size, in dp, that replaces the size of the role; std::nullopt (the default) when the role's size is used.

Definition at line 42 of file typography.cpp.

◆ getRole()

theme::TypeRole guillaume::components::Typography::getRole ( void ) const

Get the typescale role.

Returns
The role (BodyMedium by default).

Definition at line 27 of file typography.cpp.

◆ setFontSize()

Typography & guillaume::components::Typography::setFontSize ( std::optional< float > fontSize)

Override the font size of the role, or clear the override.

Only the size is replaced: the weight, line height and letter spacing still come from the role. Marks the component changed only when the value differs.

Parameters
fontSizeThe size, in dp, or std::nullopt to use the size of the role.
Returns
This component, for chaining.

Definition at line 47 of file typography.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setRole()

Typography & guillaume::components::Typography::setRole ( theme::TypeRole role)

Set the typescale role.

Marks the component changed only when the role differs.

Parameters
roleThe role systems::Typography resolves against the active theme.
Returns
This component, for chaining.

Definition at line 32 of file typography.cpp.

Here is the call graph for this function:

The documentation for this class was generated from the following files: