7#include "otype_utilities.hpp"
8#include "../utility/utility.hpp"
9#include "../macros.hpp"
13hi_export_module(hikogui.font.otype_head);
15hi_export
namespace hi {
inline namespace v1 {
17[[nodiscard]]
inline auto otype_head_parse(std::span<std::byte const> bytes)
20 big_uint16_buf_t major_version;
21 big_uint16_buf_t minor_version;
22 otype_fixed15_16_buf_t font_revision;
23 big_uint32_buf_t check_sum_adjustment;
24 big_uint32_buf_t magic_number;
25 big_uint16_buf_t flags;
26 big_uint16_buf_t units_per_em;
27 big_uint64_buf_t created;
28 big_uint64_buf_t modified;
29 otype_fword_buf_t x_min;
30 otype_fword_buf_t y_min;
31 otype_fword_buf_t x_max;
32 otype_fword_buf_t y_max;
33 big_uint16_buf_t mac_style;
34 big_uint16_buf_t lowest_rec_PPEM;
35 big_int16_buf_t font_direction_hint;
36 big_int16_buf_t index_to_loc_format;
37 big_int16_buf_t glyph_data_format;
41 bool loca_is_offset32;
45 auto const& header = implicit_cast<header_type>(bytes);
47 hi_check(*header.major_version == 1 and *header.minor_version == 0,
"'head' version is not 1.0");
48 hi_check(*header.magic_number == 0x5f0f3cf5,
"'head' magic is not 0x5f0f3cf5");
52 auto r = return_type{};
54 switch (*header.index_to_loc_format) {
56 r.loca_is_offset32 =
false;
59 r.loca_is_offset32 =
true;
62 throw parse_error(
"'head' index_to_loc_format must be 0 or 1.");
65 if (
auto const units_per_em = *header.units_per_em; units_per_em != 0.0) {
66 r.em_scale = 1.0f / units_per_em;
68 throw parse_error(
"'head' units_per_em must not be 0.0.");
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20