7#include "../geometry/geometry.hpp"
8#include "../telemetry/telemetry.hpp"
9#include "../utility/utility.hpp"
10#include "../parser/parser.hpp"
14hi_export_module(hikogui.font.otype_coverage);
16hi_export
namespace hi::inline
v1 {
19 big_int16_buf_t coverage_format;
20 big_int16_buf_t glyph_count;
24 big_int16_buf_t coverage_format;
25 big_int16_buf_t range_count;
29 big_int16_buf_t start_glyph_id;
30 big_int16_buf_t end_glyph_id;
31 big_int16_buf_t start_coverage_index;
34[[nodiscard]]
std::ptrdiff_t true_type_font::get_coverage_index(std::span<std::byte const> bytes, hi::glyph_id
glyph_id)
40 auto const header1 = make_placement_ptr<coverage_format1>(bytes, offset);
41 if (*header1->coverage_format == 1) {
42 auto const table = make_placement_array<big_uint16_buf_t>(bytes, offset, *header1->glyph_count);
45 return *item < *value;
48 if (it != table.end() and **it == *
glyph_id) {
54 }
else if (*header1->coverage_format == 2) {
56 auto const header2 = make_placement_ptr<coverage_format2>(bytes, offset);
58 auto const table = make_placement_array<coverage_format2_range>(bytes, offset, *header2->range_count);
60 auto const it =
std::lower_bound(table.begin(), table.end(), glyph_id, [](
auto const &item,
auto const &value) {
61 return *item.end_glyph_id < *value;
64 if (it != table.end() and *it->start_glyph_id <= *glyph_id and *glyph_id <= *it->end_glyph_id) {
65 return *it->start_coverage_index + *glyph_id - *it->start_glyph_id;
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
Definition otype_coverage.hpp:18
Definition otype_coverage.hpp:23
Definition otype_coverage.hpp:28
Definition tagged_id.hpp:26