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

Turns the type-scale role of a text (Body Large, Label Medium, ...) into the font metrics of the active theme. More...

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

Inheritance diagram for guillaume::systems::Typography:
Collaboration diagram for guillaume::systems::Typography:

Public Member Functions

 Typography (void)
 Create the system in the Measure phase.
 ~Typography (void) override=default
 Destroy the system. It owns no resource.
void update (const ecs::Entity::Identifier &entityIdentifier) override
 Resolve the metrics of one text for this frame.
Public Member Functions inherited from guillaume::ecs::SystemFiller< components::Typography, components::Text >
 SystemFiller (Phase phase)
 Create the system and set its signature from ComponentTypes.
virtual ~SystemFiller (void)=default
 Virtual destructor.
Public Member Functions inherited from guillaume::ecs::System
 System (Phase phase)
 Create a system that runs in a given phase, with an empty signature.
virtual ~System (void)=default
 Virtual destructor.
Phase getPhase (void) const noexcept
 Get the phase of the frame in which the system runs.
Entity::Signature getSignature (void) const noexcept
 Get the component types an entity must declare to be visited by this system.
void routine (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry, const ecs::EntityTreeTraveler &traveler)
 Run the system once over a scene: prepare(), update() on each matching entity, cleanup().
void bindComponentRegistry (ecs::ComponentRegistry &componentRegistry)
 Bind a component registry so update() can be called directly, without routine().
void unbindComponentRegistry (void)
 Drop the binding made by bindComponentRegistry().
virtual void prepare (void)
 Called once per pass, before the first update().
virtual void cleanup (void)
 Called once per pass, after the last update().

Static Public Member Functions

static void apply (ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
 Resolve the metrics of one text and write them into its components::Text.

Additional Inherited Members

Protected Member Functions inherited from guillaume::ecs::System
template<InheritFromComponent... ComponentTypes>
void setSignature (void)
 Replace the signature by the one made of the given component types.
ecs::EntityRegistry & getEntityRegistry (void)
 Get the entity registry of the scene being processed.
const ecs::EntityRegistry & getEntityRegistry (void) const
 Get the entity registry of the scene being processed, read-only.
ecs::ComponentRegistry & getComponentRegistry (void)
 Get the component registry of the scene being processed.
const ecs::ComponentRegistry & getComponentRegistry (void) const
 Get the component registry of the scene being processed, read-only.
template<InheritFromComponent ComponentType>
bool hasComponent (const ecs::Entity::Identifier &entityIdentifier) const
 Tell whether an entity has a component, in the bound registry.
template<InheritFromComponent ComponentType>
ComponentType & getComponent (const ecs::Entity::Identifier &entityIdentifier)
 Get a component of an entity from the bound registry, to read or modify it.
template<InheritFromComponent ComponentType>
const ComponentType & getComponent (const ecs::Entity::Identifier &entityIdentifier) const
 Get a component of an entity from the bound registry, read-only.
template<InheritFromComponent ComponentType>
bool requireComponent (const ecs::Entity::Identifier &entityIdentifier)
 Tell whether an entity has a component, and log a warning naming the entity and the component when it does not.

Detailed Description

Turns the type-scale role of a text (Body Large, Label Medium, ...) into the font metrics of the active theme.

Runs in the Measure phase on entities with Typography and Text.

A font size set on the Typography replaces the size of the role; the other metrics still come from the role.

It is the first system registered, ahead of systems::MeasureText in the same phase, so a text is measured with the metrics resolved here. Because it runs every frame, a change of theme reaches every text on the next frame. Call apply() to resolve a text at once, for example right after creating it:

registry.getComponent<components::Typography>(label)
systems::Typography::apply(registry, label);
Which typescale role a text uses (BodyMedium, TitleLarge, ...) and an optional explicit size.
static void apply(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Resolve the metrics of one text and write them into its components::Text.
@ LabelLarge
14 / 20, medium weight.
Definition typescale.hpp:57

The metrics of a Text that has a Typography are overwritten every frame: change the role or the Typography font size, not the Text.

See also
components::Typography, components::Text
systems::MeasureText

Definition at line 62 of file typography.hpp.

Constructor & Destructor Documentation

◆ Typography()

guillaume::systems::Typography::Typography ( void )

Create the system in the Measure phase.

Definition at line 29 of file typography.cpp.

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

Member Function Documentation

◆ apply()

void guillaume::systems::Typography::apply ( ecs::ComponentRegistry & componentRegistry,
const ecs::Entity::Identifier & entityIdentifier )
static

Resolve the metrics of one text and write them into its components::Text.

The Text is marked changed only when a metric differs from the one it already holds.

Parameters
componentRegistryThe registry holding the components.
entityIdentifierThe text entity. It must have Typography and Text.
Exceptions
ecs::EntityComponentNotFoundExceptionWhen one of the two components is missing.

Definition at line 35 of file typography.cpp.

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

◆ update()

void guillaume::systems::Typography::update ( const ecs::Entity::Identifier & entityIdentifier)
overridevirtual

Resolve the metrics of one text for this frame.

Parameters
entityIdentifierThe text entity. It is skipped, with a log message, when one of the two components is missing.

Implements guillaume::ecs::System.

Definition at line 53 of file typography.cpp.

Here is the call graph for this function:

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