guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
typescale.hpp
1/*
2 Copyright (c) 2026 ETIB Corporation
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in
6 the Software without restriction, including without limitation the rights to
7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8 of the Software, and to permit persons to whom the Software is furnished to do
9 so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22
23#pragma once
24
25#include <array>
26#include <cstddef>
27#include <cstdint>
28#include <string>
29
30namespace guillaume::theme
31{
32
66
71 enum class FontWeight : std::uint16_t {
72 Regular = 400,
73 Medium = 500
74 };
75
83 struct TypeToken {
84 std::string fontFamily { "Roboto" };
86 float fontSize { 14.0f };
87 float lineHeight {
88 20.0f
89 };
91 0.0f
92 };
93 };
94
102 const std::string &fontPath(FontWeight weight);
103
121 {
122 public:
127 Typescale(void);
128
132 ~Typescale(void) = default;
133
140 const TypeToken &get(TypeRole role) const;
141
151 void set(TypeRole role, const TypeToken &token);
152
153 private:
154 std::array<TypeToken, static_cast<std::size_t>(TypeRole::Count)>
155 _tokens;
156 };
157
158} // namespace guillaume::theme
~Typescale(void)=default
Default destructor.
void set(TypeRole role, const TypeToken &token)
Replace the text style of a role.
Definition typescale.cpp:89
const TypeToken & get(TypeRole role) const
Get the text style of a role.
Definition typescale.cpp:84
Typescale(void)
Create the scale with the Material 3 baseline styles listed in TypeRole.
Definition typescale.cpp:59
Design tokens: colors, type scale, shapes, elevation, motion and spacing. Read them through guillaume...
const std::string & fontPath(FontWeight weight)
Get the font file shipped with the library for a weight.
Definition typescale.cpp:52
TypeRole
The named text styles of Material Design 3: what a piece of text is, not how big it is.
Definition typescale.hpp:47
@ BodyLarge
16 / 24, regular.
Definition typescale.hpp:60
@ LabelSmall
11 / 16, medium weight.
Definition typescale.hpp:59
@ DisplayLarge
57 / 64, regular.
Definition typescale.hpp:48
@ LabelMedium
12 / 16, medium weight.
Definition typescale.hpp:58
@ HeadlineLarge
32 / 40, regular.
Definition typescale.hpp:51
@ TitleSmall
14 / 20, medium weight.
Definition typescale.hpp:56
@ BodySmall
12 / 16, regular.
Definition typescale.hpp:62
@ TitleLarge
22 / 28, regular.
Definition typescale.hpp:54
@ DisplayMedium
45 / 52, regular.
Definition typescale.hpp:49
@ LabelLarge
14 / 20, medium weight.
Definition typescale.hpp:57
@ TitleMedium
16 / 24, medium weight.
Definition typescale.hpp:55
@ HeadlineMedium
28 / 36, regular.
Definition typescale.hpp:52
@ DisplaySmall
36 / 44, regular.
Definition typescale.hpp:50
@ Default
14 / 20, regular: text with no specific role.
Definition typescale.hpp:63
@ HeadlineSmall
24 / 32, regular.
Definition typescale.hpp:53
@ BodyMedium
14 / 20, regular.
Definition typescale.hpp:61
@ Count
Number of roles; not a role.
Definition typescale.hpp:64
FontWeight
Font weights available to the typescale. The value is the usual numeric weight (400 regular,...
Definition typescale.hpp:71
@ Medium
12 dp (cards).
Definition tokens.hpp:46
@ Count
Number of roles; not a role.
Definition tokens.hpp:50
One text style: everything needed to measure and draw a piece of text.
Definition typescale.hpp:83
float letterSpacing
Extra space between characters, in dp.
Definition typescale.hpp:90
FontWeight fontWeight
Font weight.
Definition typescale.hpp:85
std::string fontFamily
Font family name.
Definition typescale.hpp:84
float fontSize
Font size, in dp.
Definition typescale.hpp:86
float lineHeight
Distance between two baselines, in dp.
Definition typescale.hpp:87