HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
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
14namespace tt {
15
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
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 fmt::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
57}
Definition font_description.hpp:16
A font variant is one of 16 different fonts that can be part of a family.
Definition font_variant.hpp:16
Unicode Ranges based on the OS/2 table in TrueType fonts.
Definition unicode_ranges.hpp:15