5#include "true_type_font.hpp"
6#include "../geometry/module.hpp"
7#include "../telemetry/telemetry.hpp"
8#include "../utility/utility.hpp"
9#include "../parser/parser.hpp"
13hi_export_module(hikogui.font.otype_coverage);
15hi_export
namespace hi::inline
v1 {
18 big_int16_buf_t coverage_format;
19 big_int16_buf_t glyph_count;
23 big_int16_buf_t coverage_format;
24 big_int16_buf_t range_count;
28 big_int16_buf_t start_glyph_id;
29 big_int16_buf_t end_glyph_id;
30 big_int16_buf_t start_coverage_index;
33[[nodiscard]]
std::ptrdiff_t true_type_font::get_coverage_index(std::span<std::byte const> bytes, hi::glyph_id glyph_id)
37 hi_assert_or_return(*glyph_id >= 0 && *glyph_id < num_glyphs, -2);
39 hilet header1 = make_placement_ptr<coverage_format1>(bytes, offset);
40 if (*header1->coverage_format == 1) {
41 hilet table = make_placement_array<big_uint16_buf_t>(bytes, offset, *header1->glyph_count);
43 hilet it =
std::lower_bound(table.begin(), table.end(), glyph_id, [](hilet &item, hilet &value) {
44 return *item < *value;
47 if (it != table.end() and **it == *glyph_id) {
53 }
else if (*header1->coverage_format == 2) {
55 hilet header2 = make_placement_ptr<coverage_format2>(bytes, offset);
57 hilet table = make_placement_array<coverage_format2_range>(bytes, offset, *header2->range_count);
59 hilet it =
std::lower_bound(table.begin(), table.end(), glyph_id, [](hilet &item, hilet &value) {
60 return *item.end_glyph_id < *value;
63 if (it != table.end() and *it->start_glyph_id <= *glyph_id and *glyph_id <= *it->end_glyph_id) {
64 return *it->start_coverage_index + *glyph_id - *it->start_glyph_id;
DOXYGEN BUG.
Definition algorithm.hpp:16
Definition otype_coverage.hpp:17
Definition otype_coverage.hpp:22
Definition otype_coverage.hpp:27