HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
otype_maxp.hpp
1// Copyright Take Vos 2023.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "otype_utilities.hpp"
8#include "../utility/module.hpp"
9#include <span>
10#include <cstddef>
11
12namespace hi { inline namespace v1 {
13
14[[nodiscard]] inline auto otype_maxp_parse(std::span<std::byte const> bytes)
15{
16 struct header_type_05 {
17 big_uint32_buf_t version;
18 big_uint16_buf_t num_glyphs;
19 };
20
21 struct header_type_10 {
22 big_uint32_buf_t version;
23 big_uint16_buf_t num_glyphs;
24 big_uint16_buf_t max_points;
25 big_uint16_buf_t max_contours;
26 big_uint16_buf_t max_component_points;
27 big_uint16_buf_t max_component_contours;
28 big_uint16_buf_t max_zones;
29 big_uint16_buf_t max_twilight_points;
30 big_uint16_buf_t max_storage;
31 big_uint16_buf_t max_function_defs;
32 big_uint16_buf_t max_instruction_defs;
33 big_uint16_buf_t max_stack_elements;
34 big_uint16_buf_t max_size_of_instructions;
35 big_uint16_buf_t max_component_elements;
36 big_uint16_buf_t max_component_depth;
37 };
38
39 struct return_type {
40 uint16_t num_glyphs;
41 };
42
43 hilet& header = implicit_cast<header_type_05>(bytes);
44 hilet version = *header.version;
45 hi_check(version == 0x00010000 || version == 0x00005000, "MAXP version must be 0.5 or 1.0");
46
47 auto r = return_type{};
48 r.num_glyphs = *header.num_glyphs;
49 return r;
50}
51
52}} // namespace hi::v1
#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