HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
text_theme.hpp
1// Copyright Take Vos 2021-2022.
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 "text_style.hpp"
8#include "../concurrency/module.hpp"
9#include <vector>
10#include <array>
11#include <algorithm>
12#include <cstdint>
13
14namespace hi::inline v1 {
15
16class text_theme : public std::vector<text_style> {
17public:
18 using std::vector<text_style>::vector;
19
20 [[nodiscard]] text_style const &
21 find(text_phrasing phrasing, iso_639 language, iso_3166 region, iso_15924 script) const noexcept
22 {
23 for (hilet& style : *this) {
24 if (matches(style, phrasing, language, region, script)) {
25 return style;
26 }
27 }
28 hi_axiom(not empty());
29 return back();
30 }
31};
32
33} // namespace hi::inline v1
34
35template<typename CharT>
36struct std::formatter<hi::text_theme, CharT> : std::formatter<std::string_view, CharT> {
37 auto format(hi::text_theme const& t, auto& fc)
38 {
39 return std::formatter<std::string_view, CharT>::format(std::format("#{}", t.size()), fc);
40 }
41};
#define hi_axiom(expression,...)
Specify an axiom; an expression that is true.
Definition assert.hpp:253
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
text_phrasing
Text phrasing.
Definition text_phrasing.hpp:22
DOXYGEN BUG.
Definition algorithm.hpp:13
constexpr bool matches(text_phrasing_mask const &lhs, text_phrasing const &rhs) noexcept
Check if the text-phrasing is included in the text-phrasing-mask.
Definition text_phrasing.hpp:216
geometry/margins.hpp
Definition cache.hpp:11
ISO-15924 script code.
Definition iso_15924.hpp:17
ISO-3166 country code.
Definition iso_3166.hpp:15
ISO-639 language code.
Definition iso_639.hpp:23
Definition text_theme.hpp:16