HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
text_style.hpp
1// Copyright Take Vos 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 "font_description.hpp"
8#include "text_decoration.hpp"
9#include "font_family_id.hpp"
10#include "../color/color.hpp"
11#include <fmt/format.h>
12#include <ostream>
13
14namespace tt {
15
16struct text_style {
17 static constexpr float default_dpi = 84.0f;
18 static constexpr float dpi_scale = default_dpi / 72.0f;
19
20 font_family_id family_id;
21 font_variant variant;
22 float size;
24 text_decoration decoration;
25
26 text_style() noexcept :
27 family_id(), variant(), size(0.0), color(), decoration(text_decoration::None) {}
28
29 text_style(tt::font_family_id family_id, tt::font_variant variant, float size, tt::color color, text_decoration decoration) noexcept :
30 family_id(family_id), variant(variant), size(size), color(color), decoration(decoration) {}
31
33 std::string_view family_name,
34 tt::font_variant variant,
35 float size,
37 text_decoration decoration) noexcept;
38
39 text_style(text_style const &) noexcept = default;
40 text_style(text_style &&) noexcept = default;
41 text_style &operator=(text_style const &) noexcept = default;
42 text_style &operator=(text_style &&) noexcept = default;
43
44 float scaled_size() const noexcept {
45 return size * dpi_scale;
46 }
47
48 [[nodiscard]] friend std::string to_string(text_style const &rhs) noexcept {
49 // XXX - fmt:: no longer can format tagged_ids??????
50
51 //return fmt::format("<text_style id={},v={},s={},c={},d={}>",
52 // rhs.family_id, rhs.variant, rhs.size, rhs.color, rhs.decoration
53 //);
54 tt_not_implemented();
55 }
56
57 friend std::ostream &operator<<(std::ostream &lhs, text_style const &rhs) {
58 return lhs << to_string(rhs);
59 }
60};
61
62}
This is a RGBA floating point color.
Definition color.hpp:39
A font variant is one of 16 different fonts that can be part of a family.
Definition font_variant.hpp:16
Definition text_style.hpp:16