7#include "font_variant.hpp"
8#include "text_decoration.hpp"
9#include "font_family_id.hpp"
10#include "text_phrasing.hpp"
11#include "semantic_text_style.hpp"
12#include "../color/color.hpp"
13#include "../i18n/iso_15924.hpp"
14#include "../i18n/iso_639.hpp"
15#include "../numbers.hpp"
17#include "../stable_set.hpp"
19#include "../assert.hpp"
24namespace hi::inline v1 {
28 text_phrasing_mask phrasing_mask;
36 text_decoration decoration;
41 text_phrasing_mask phrasing_mask,
48 text_decoration decoration) noexcept :
49 phrasing_mask(phrasing_mask),
50 language_filter(language_filter),
51 script_filter(script_filter),
56 decoration(decoration)
60 [[nodiscard]]
size_t hash()
const noexcept
78 if (not to_bool(phrasing_mask & to_text_phrasing_mask(phrasing))) {
84 if (script_filter and script and script_filter != script) {
97 [[nodiscard]]
size_t operator()(hi::text_sub_style
const& rhs)
const noexcept
103namespace hi::inline v1::detail {
109 using iterator = vector_type::const_iterator;
117 hi_axiom(not empty());
118 hi_axiom(all(back().phrasing_mask));
119 hi_axiom(back().language_filter.empty());
120 hi_axiom(back().script_filter.empty());
123 [[nodiscard]]
bool empty()
const noexcept
125 return _sub_styles.
empty();
128 explicit operator bool()
const noexcept
133 [[nodiscard]]
size_t hash()
const noexcept
136 for (
hilet& sub_style : _sub_styles) {
142 [[nodiscard]]
reference back()
const noexcept
144 return _sub_styles.
back();
147 [[nodiscard]] iterator begin()
const noexcept
149 return _sub_styles.
begin();
152 [[nodiscard]] iterator end()
const noexcept
154 return _sub_styles.
end();
164 [[nodiscard]]
size_t operator()(hi::detail::text_style_impl
const& rhs)
const noexcept
170namespace hi::inline v1 {
172inline auto text_styles = stable_set<text_style_impl>{};
177 using int_type = uint16_t;
181 constexpr text_style(semantic_text_style rhs) noexcept : _value(0xff00 + to_underlying(rhs)) {}
186 if (index < 0xff00) {
187 _value = narrow_cast<uint16_t>(index);
189 hi_log_error_once(
"text-style:error:too-many",
"Too many text-styles");
195 [[nodiscard]]
constexpr bool empty()
const noexcept
197 return _value == 0xffff;
200 constexpr explicit operator bool()
const noexcept
205 [[nodiscard]]
constexpr bool is_semantic()
const noexcept
207 hi_axiom(not empty());
208 return _value >= 0xff00;
211 constexpr explicit operator semantic_text_style()
const noexcept
213 return static_cast<semantic_text_style
>(narrow_cast<std::underlying_type_t<semantic_text_style>>(_value - 0xff00));
218 hi_axiom(not empty());
219 if (_value < 0xff00) {
222 hi_not_implemented();
228 hi_axiom(not empty());
229 if (_value < 0xff00) {
230 return detail::text_styles[_value].back();
232 hi_not_implemented();
238 for (
hilet& style : detail::text_styles[_value]) {
239 if (style.matches(phrasing,
language, script)) {
#define hilet
Invariant should be the default for variables.
Definition required.hpp:23
This is a RGBA floating point color.
Definition color.hpp:39
ISO-15924 script code.
Definition iso_15924.hpp:18
ISO-639 language code.
Definition iso_639.hpp:25
Definition language.hpp:18
font_book keeps track of multiple fonts.
Definition font_book.hpp:30
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:27
Definition text_style.hpp:105
Definition text_style.hpp:175
Definition concepts.hpp:39
T operator()(T... args)
Definition datum.hpp:2458