HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
FontDescription.hpp
1// Copyright 2020 Pokitec
2// All rights reserved.
3
4#pragma once
5
6#include "TTauri/Text/UnicodeRanges.hpp"
7#include "TTauri/Text/GlyphID.hpp"
8#include "TTauri/Text/FontWeight.hpp"
9#include "TTauri/Text/FontVariant.hpp"
10#include "TTauri/Foundation/exceptions.hpp"
11#include "TTauri/Foundation/required.hpp"
12
13namespace tt {
14
16 std::string family_name;
17 std::string sub_family_name;
18
19 bool monospace = false;
20 bool serif = false;
21 bool italic = false;
22 bool condensed = false;
23 FontWeight weight = FontWeight::Regular;
24 float optical_size = 12.0;
25
26 UnicodeRanges unicode_ranges;
27
28 float xHeight = 0.0;
29 float HHeight = 0.0;
30
31
32 [[nodiscard]] FontVariant font_variant() const noexcept {
33 return {weight, italic};
34 }
35
36 [[nodiscard]] friend std::string to_string(FontDescription const &rhs) noexcept {
37 return fmt::format("{} - {}: {}{}{}{}{} {} {}",
38 rhs.family_name,
39 rhs.sub_family_name,
40 rhs.monospace ? 'M' : '_',
41 rhs.serif ? 'S': '_',
42 rhs.italic ? 'I': '_',
43 rhs.condensed ? 'C': '_',
44 to_char(rhs.weight),
45 rhs.optical_size,
46 rhs.unicode_ranges
47 );
48 }
49
50 friend std::ostream &operator<<(std::ostream &lhs, FontDescription const &rhs) {
51 return lhs << to_string(rhs);
52 }
53};
54
55
56}
Definition FontDescription.hpp:15
A font variant is one of 16 different fonts that can be part of a family.
Definition FontVariant.hpp:15
Unicode Ranges based on the OS/2 table in TrueType fonts.
Definition UnicodeRanges.hpp:13