7#include "otype_utilities.hpp"
8#include "../utility/module.hpp"
12namespace hi {
inline namespace v1 {
14[[nodiscard]]
inline auto otype_head_parse(std::span<std::byte const> bytes)
17 big_uint16_buf_t major_version;
18 big_uint16_buf_t minor_version;
19 otype_fixed15_16_buf_t font_revision;
20 big_uint32_buf_t check_sum_adjustment;
21 big_uint32_buf_t magic_number;
22 big_uint16_buf_t flags;
23 big_uint16_buf_t units_per_em;
24 big_uint64_buf_t created;
25 big_uint64_buf_t modified;
26 otype_fword_buf_t x_min;
27 otype_fword_buf_t y_min;
28 otype_fword_buf_t x_max;
29 otype_fword_buf_t y_max;
30 big_uint16_buf_t mac_style;
31 big_uint16_buf_t lowest_rec_PPEM;
32 big_int16_buf_t font_direction_hint;
33 big_int16_buf_t index_to_loc_format;
34 big_int16_buf_t glyph_data_format;
38 bool loca_is_offset32;
42 hilet& header = implicit_cast<header_type>(bytes);
44 hi_check(*header.major_version == 1 and *header.minor_version == 0,
"'head' version is not 1.0");
45 hi_check(*header.magic_number == 0x5f0f3cf5,
"'head' magic is not 0x5f0f3cf5");
49 auto r = return_type{};
51 switch (*header.index_to_loc_format) {
53 r.loca_is_offset32 =
false;
56 r.loca_is_offset32 =
true;
59 throw parse_error(
"'head' index_to_loc_format must be 0 or 1.");
62 if (
hilet units_per_em = *header.units_per_em; units_per_em != 0.0) {
63 r.em_scale = 1.0f / units_per_em;
65 throw parse_error(
"'head' units_per_em must not be 0.0.");
#define hi_check(expression, message,...)
Check if the expression is valid, or throw a parse_error.
Definition assert.hpp:110
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11