HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
ttauri
text
font_description.hpp
1
// Copyright Take Vos 2020-2021.
2
// Distributed under the Boost Software License, Version 1.0.
3
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5
#pragma once
6
7
#include "unicode_ranges.hpp"
8
#include "glyph_id.hpp"
9
#include "font_weight.hpp"
10
#include "font_variant.hpp"
11
#include "../exception.hpp"
12
#include "../required.hpp"
13
14
namespace
tt {
15
16
struct
font_description
{
17
std::string
family_name;
18
std::string
sub_family_name;
19
20
bool
monospace =
false
;
21
bool
serif =
false
;
22
bool
italic =
false
;
23
bool
condensed =
false
;
24
font_weight weight = font_weight::Regular;
25
float
optical_size = 12.0;
26
27
unicode_ranges
unicode_ranges
;
28
29
float
xHeight = 0.0;
30
float
HHeight = 0.0;
31
float
DigitWidth = 0.0;
32
33
[[nodiscard]]
font_variant
font_variant
()
const
noexcept
{
34
return
{weight, italic};
35
}
36
37
[[nodiscard]]
friend
std::string
to_string(
font_description
const
&rhs)
noexcept
{
38
return
std::format(
"{} - {}: {}{}{}{}{} {} {}"
,
39
rhs.family_name,
40
rhs.sub_family_name,
41
rhs.monospace ?
'M'
:
'_'
,
42
rhs.serif ?
'S'
:
'_'
,
43
rhs.italic ?
'I'
:
'_'
,
44
rhs.condensed ?
'C'
:
'_'
,
45
to_char(rhs.weight),
46
rhs.optical_size,
47
rhs.unicode_ranges
48
);
49
}
50
51
friend
std::ostream
&operator<<(
std::ostream
&lhs,
font_description
const
&rhs) {
52
return
lhs << to_string(rhs);
53
}
54
};
55
56
template
<
typename
CharT>
57
struct
std::formatter<tt::
font_description
, CharT> : std::formatter<std::string_view, CharT> {
58
auto
format(
tt::font_description
const
&t,
auto
&fc)
59
{
60
return
std::formatter<std::string_view, CharT>::format(to_string(t), fc);
61
}
62
};
63
64
65
}
tt::font_description
Definition
font_description.hpp:16
tt::font_variant
A font variant is one of 16 different fonts that can be part of a family.
Definition
font_variant.hpp:16
tt::unicode_ranges
Unicode Ranges based on the OS/2 table in TrueType fonts.
Definition
unicode_ranges.hpp:15
std::ostream
std::string
Generated on Mon Apr 22 2024 12:53:38 for HikoGUI by
1.10.0