7#include "text_decoration.hpp"
8#include "semantic_text_style.hpp"
10#include "../i18n/i18n.hpp"
11#include "../unicode/unicode.hpp"
12#include "../utility/utility.hpp"
13#include "../font/font.hpp"
14#include "../telemetry/telemetry.hpp"
15#include "../container/container.hpp"
16#include "../macros.hpp"
21hi_export_module(hikogui.text.text_style);
23hi_export
namespace hi::inline
v1 {
26 phrasing_mask phrasing_mask;
28 iso_15924 script_filter;
39 hi::phrasing_mask phrasing_mask,
41 iso_15924 script_filter,
47 phrasing_mask(phrasing_mask),
48 language_filter(language_filter),
49 script_filter(script_filter),
54 decoration(decoration)
58 [[nodiscard]]
size_t hash()
const noexcept
72 [[nodiscard]] length_f cap_height()
const noexcept
78 [[nodiscard]] length_f x_height()
const noexcept
86 if (not to_bool(phrasing_mask & to_phrasing_mask(
phrasing))) {
89 if (language_filter and language and language_filter != language) {
92 if (script_filter and script and script_filter != script) {
105 [[nodiscard]]
size_t operator()(hi::text_sub_style
const& rhs)
const noexcept
111hi_export
namespace hi::inline
v1::detail {
117 using iterator = vector_type::const_iterator;
125 hi_assert(not empty());
126 hi_assert(all(back().phrasing_mask));
127 hi_assert(back().language_filter.empty());
128 hi_assert(back().script_filter.empty());
131 [[nodiscard]]
bool empty()
const noexcept
133 return _sub_styles.
empty();
136 explicit operator bool()
const noexcept
141 [[nodiscard]]
size_t hash()
const noexcept
144 for (
auto const& sub_style : _sub_styles) {
150 [[nodiscard]] reference back()
const noexcept
152 return _sub_styles.
back();
155 [[nodiscard]] iterator begin()
const noexcept
157 return _sub_styles.
begin();
160 [[nodiscard]] iterator end()
const noexcept
162 return _sub_styles.
end();
172 [[nodiscard]]
size_t operator()(hi::detail::text_style_impl
const& rhs)
const noexcept
178hi_export
namespace hi::inline
v1 {
180inline auto text_styles = stable_set<text_style_impl>{};
185 using int_type = uint16_t;
192 [[nodiscard]]
constexpr friend bool operator==(
text_style const&,
text_style const&)
noexcept =
default;
194 constexpr text_style(semantic_text_style rhs) noexcept : _value(0xff00 + std::to_underlying(rhs)) {}
198 auto const index = detail::text_styles.emplace(
std::move(rhs));
199 if (index < 0xff00) {
200 _value = narrow_cast<uint16_t>(index);
202 hi_log_error_once(
"text-style:error:too-many",
"Too many text-styles");
208 [[nodiscard]]
constexpr bool empty()
const noexcept
210 return _value == 0xffff;
213 constexpr explicit operator bool()
const noexcept
218 [[nodiscard]]
constexpr bool is_semantic()
const noexcept
220 hi_assert(not empty());
221 return _value >= 0xff00;
224 constexpr explicit operator semantic_text_style()
const noexcept
226 return static_cast<semantic_text_style
>(narrow_cast<std::underlying_type_t<semantic_text_style>>(_value - 0xff00));
231 hi_axiom(not empty());
232 if (_value < 0xff00) {
235 hi_not_implemented();
241 hi_axiom(not empty());
242 if (_value < 0xff00) {
243 return detail::text_styles[_value].back();
245 hi_not_implemented();
251 for (
auto const& style : detail::text_styles[_value]) {
252 if (style.matches(
phrasing, language, script)) {
phrasing
Phrasing.
Definition phrasing.hpp:33
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
text_decoration
Describes how a grapheme should be underlined when rendering the text.
Definition text_decoration.hpp:24
hi_export font const & find_font(font_family_id family_id, font_variant variant=font_variant{}) noexcept
Find a font closest to the variant.
Definition font_book.hpp:415
constexpr bool matches(phrasing_mask const &lhs, phrasing const &rhs) noexcept
Check if the text-phrasing is included in the text-phrasing-mask.
Definition phrasing.hpp:230
This is a RGBA floating point color.
Definition color_intf.hpp:49
Definition font_font.hpp:31
font_metrics_em metrics
The metrics of a font.
Definition font_font.hpp:65
au::Quantity< Unit, T > cap_height
Height of capital letter, or height of the letter 'H'.
Definition font_metrics.hpp:41
au::Quantity< Unit, T > x_height
Height of lower case characters without ascenders or descenders, or the small letter 'x'.
Definition font_metrics.hpp:45
A font variant is one of 16 different fonts that can be part of a family.
Definition font_variant.hpp:27
ISO-639 language code.
Definition iso_639.hpp:29
Definition text_style.hpp:25
Definition text_style.hpp:113
Definition text_style.hpp:183