11#include "glyph_id.hpp"
12#include "../algorithm/module.hpp"
13#include "../utility/utility.hpp"
14#include "../macros.hpp"
22hi_export_module(hikogui.font.font_char_map);
24namespace hi {
inline namespace v1 {
42 [[
nodiscard]]
constexpr bool empty()
const noexcept
70 for (hilet&
entry : _map) {
73 if (
not mask.test(
cp)) {
88 [[
nodiscard]]
constexpr void add(
char32_t start_code_point,
char32_t end_code_point, uint16_t start_glyph)
noexcept
93 hi_axiom(start_code_point <= end_code_point);
96 hi_axiom(start_glyph +
todo < 0xffff,
"Only glyph-ids 0 through 0xfffe are valid");
100 hi_axiom(
doing != 0);
123 return a.end_code_point < b.end_code_point;
128 while (
it != _map.
end()) {
129 hi_axiom(
prev_it->end_code_point <
it->start_code_point());
134 hi_axiom(
move_count <= entry_type::max_count);
169 hi_assert(_prepared);
180 constexpr static size_t max_count = 0x1'0000;
182 char32_t end_code_point;
183 uint16_t start_glyph;
186 constexpr entry_type(
char32_t start_code_point,
char32_t end_code_point, uint16_t start_glyph)
noexcept :
187 end_code_point(end_code_point),
188 start_glyph(start_glyph),
191 hi_axiom(start_code_point <= end_code_point);
208 return end_code_point - _count;
216 [[
nodiscard]]
constexpr friend bool mergable(entry_type
const& lhs, entry_type
const& rhs)
noexcept
218 return lhs.end_code_point + 1 == rhs.start_code_point()
and lhs.end_glyph() + 1 == rhs.start_glyph;
221 [[
nodiscard]]
constexpr glyph_id get(
char32_t code_point)
const noexcept
243 bool _prepared =
false;
DOXYGEN BUG.
Definition algorithm.hpp:16
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
Character map of a font.
Definition font_char_map.hpp:34
constexpr void reserve(size_t n)
Reserve space for a set of ranges to be added.
Definition font_char_map.hpp:50
glyph_id find(char32_t code_point) const noexcept
Find a glyph for a code_point.
Definition font_char_map.hpp:166
constexpr size_t count() const noexcept
Get the number of code-points supported by the char-map.
Definition font_char_map.hpp:57
constexpr void add(char32_t start_code_point, char32_t end_code_point, uint16_t start_glyph) noexcept
Add a range of code points.
Definition font_char_map.hpp:88
constexpr size_t update_mask(std::bitset< 0x11 '0000 > &mask) const noexcept
Update a code-point mask.
Definition font_char_map.hpp:67
void prepare() noexcept
Prepare the map for searching.
Definition font_char_map.hpp:115
T emplace_back(T... args)
T shrink_to_fit(T... args)