7#include "text_decoration.hpp"
8#include "semantic_text_style.hpp"
9#include "../color/module.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/module.hpp"
16#include "../macros.hpp"
24 phrasing_mask phrasing_mask;
26 iso_15924 script_filter;
37 hi::phrasing_mask phrasing_mask,
39 iso_15924 script_filter,
45 phrasing_mask(phrasing_mask),
46 language_filter(language_filter),
47 script_filter(script_filter),
52 decoration(decoration)
56 [[nodiscard]]
size_t hash()
const noexcept
70 [[nodiscard]]
float cap_height()
const noexcept
76 [[nodiscard]]
float x_height()
const noexcept
84 if (not to_bool(phrasing_mask & to_phrasing_mask(
phrasing))) {
87 if (language_filter and language and language_filter != language) {
90 if (script_filter and script and script_filter != script) {
103 [[nodiscard]]
size_t operator()(hi::text_sub_style
const& rhs)
const noexcept
115 using iterator = vector_type::const_iterator;
123 hi_assert(not empty());
124 hi_assert(all(back().phrasing_mask));
125 hi_assert(back().language_filter.empty());
126 hi_assert(back().script_filter.empty());
129 [[nodiscard]]
bool empty()
const noexcept
131 return _sub_styles.
empty();
134 explicit operator bool()
const noexcept
139 [[nodiscard]]
size_t hash()
const noexcept
142 for (hilet& sub_style : _sub_styles) {
148 [[nodiscard]] reference back()
const noexcept
150 return _sub_styles.
back();
153 [[nodiscard]] iterator begin()
const noexcept
155 return _sub_styles.
begin();
158 [[nodiscard]] iterator end()
const noexcept
160 return _sub_styles.
end();
170 [[nodiscard]]
size_t operator()(hi::detail::text_style_impl
const& rhs)
const noexcept
178inline auto text_styles = stable_set<text_style_impl>{};
183 using int_type = uint16_t;
190 [[nodiscard]]
constexpr friend bool operator==(
text_style const&,
text_style const&)
noexcept =
default;
192 constexpr text_style(semantic_text_style rhs) noexcept : _value(0xff00 + std::to_underlying(rhs)) {}
196 hilet index = detail::text_styles.emplace(
std::move(rhs));
197 if (index < 0xff00) {
198 _value = narrow_cast<uint16_t>(index);
200 hi_log_error_once(
"text-style:error:too-many",
"Too many text-styles");
206 [[nodiscard]]
constexpr bool empty()
const noexcept
208 return _value == 0xffff;
211 constexpr explicit operator bool()
const noexcept
216 [[nodiscard]]
constexpr bool is_semantic()
const noexcept
218 hi_assert(not empty());
219 return _value >= 0xff00;
222 constexpr explicit operator semantic_text_style()
const noexcept
224 return static_cast<semantic_text_style
>(narrow_cast<std::underlying_type_t<semantic_text_style>>(_value - 0xff00));
229 hi_axiom(not empty());
230 if (_value < 0xff00) {
233 hi_not_implemented();
239 hi_axiom(not empty());
240 if (_value < 0xff00) {
241 return detail::text_styles[_value].back();
243 hi_not_implemented();
249 for (hilet& style : detail::text_styles[_value]) {
250 if (style.matches(
phrasing, language, script)) {
phrasing
Phrasing.
Definition phrasing.hpp:30
DOXYGEN BUG.
Definition algorithm.hpp:16
text_decoration
Describes how a grapheme should be underlined when rendering the text.
Definition text_decoration.hpp:23
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:412
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:227
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
This is a RGBA floating point color.
Definition color.hpp:45
Definition font_font.hpp:31
hi::font_metrics metrics
The metrics of a font.
Definition font_font.hpp:67
A font variant is one of 16 different fonts that can be part of a family.
Definition font_variant.hpp:19
ISO-639 language code.
Definition iso_639.hpp:25
Definition text_style.hpp:23
Definition text_style.hpp:111
Definition text_style.hpp:181