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_variant.hpp"
8#include "text_decoration.hpp"
9#include "font_family_id.hpp"
10#include "../color/color.hpp"
11#include <format>
12#include <ostream>
13
14namespace tt {
15class font_book;
16
17struct text_style {
18 static constexpr float default_dpi = 84.0f;
19 static constexpr float dpi_scale = default_dpi / 72.0f;
20
21 font_family_id family_id;
22 font_variant variant;
23 float size;
25 text_decoration decoration;
26
27 text_style() noexcept :
28 family_id(), variant(), size(0.0), color(), decoration(text_decoration::None) {}
29
30 text_style(tt::font_family_id family_id, tt::font_variant variant, float size, tt::color color, text_decoration decoration) noexcept :
31 family_id(family_id), variant(variant), size(size), color(color), decoration(decoration) {}
32
33 text_style(text_style const &) noexcept = default;
34 text_style(text_style &&) noexcept = default;
35 text_style &operator=(text_style const &) noexcept = default;
36 text_style &operator=(text_style &&) noexcept = default;
37
38 float scaled_size() const noexcept {
39 return size * dpi_scale;
40 }
41
42 [[nodiscard]] friend std::string to_string(text_style const &rhs) noexcept {
43 // XXX - fmt:: no longer can format tagged_ids??????
44
45 //return std::format("<text_style id={},v={},s={},c={},d={}>",
46 // rhs.family_id, rhs.variant, rhs.size, rhs.color, rhs.decoration
47 //);
48 tt_not_implemented();
49 }
50
51 friend std::ostream &operator<<(std::ostream &lhs, text_style const &rhs) {
52 return lhs << to_string(rhs);
53 }
54};
55
56}
This is a RGBA floating point color.
Definition color.hpp:36
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:17