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/utility.hpp"
9#include "../macros.hpp"
10#include <span>
11#include <cstddef>
12
13hi_export_module(hikogui.font.maxp);
14
15hi_export namespace hi { inline namespace v1 {
16
17[[nodiscard]] inline auto otype_maxp_parse(std::span<std::byte const> bytes)
18{
19 struct header_type_05 {
20 big_uint32_buf_t version;
21 big_uint16_buf_t num_glyphs;
22 };
23
24 struct header_type_10 {
25 big_uint32_buf_t version;
26 big_uint16_buf_t num_glyphs;
27 big_uint16_buf_t max_points;
28 big_uint16_buf_t max_contours;
29 big_uint16_buf_t max_component_points;
30 big_uint16_buf_t max_component_contours;
31 big_uint16_buf_t max_zones;
32 big_uint16_buf_t max_twilight_points;
33 big_uint16_buf_t max_storage;
34 big_uint16_buf_t max_function_defs;
35 big_uint16_buf_t max_instruction_defs;
36 big_uint16_buf_t max_stack_elements;
37 big_uint16_buf_t max_size_of_instructions;
38 big_uint16_buf_t max_component_elements;
39 big_uint16_buf_t max_component_depth;
40 };
41
42 struct return_type {
43 uint16_t num_glyphs;
44 };
45
46 auto const& header = implicit_cast<header_type_05>(bytes);
47 auto const version = *header.version;
48 hi_check(version == 0x00010000 || version == 0x00005000, "MAXP version must be 0.5 or 1.0");
49
50 auto r = return_type{};
51 r.num_glyphs = *header.num_glyphs;
52 return r;
53}
54
55}} // namespace hi::v1
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20