7#include "otype_utilities.hpp"
9#include "../macros.hpp"
13hi_export_module(hikogui.font.otype_glyf);
15hi_export
namespace hi {
inline namespace v1 {
17constexpr uint16_t otype_glyf_flag_arg1_and_arg2_are_words = 0x0001;
18constexpr uint16_t otype_glyf_flag_args_are_xy_values = 0x0002;
19constexpr uint16_t otype_glyf_flag_round_xy_to_grid = 0x0004;
20constexpr uint16_t otype_glyf_flag_has_scale = 0x0008;
21constexpr uint16_t otype_glyf_flag_more_components = 0x0020;
22constexpr uint16_t otype_glyf_flag_has_xy_scale = 0x0040;
23constexpr uint16_t otype_glyf_flag_has_2x2 = 0x0080;
24constexpr uint16_t otype_glyf_flag_instructions = 0x0100;
25constexpr uint16_t otype_glyf_flag_use_this_glyph_metrics = 0x0200;
26constexpr uint16_t otype_glyf_flag_overlap_compound = 0x0400;
27constexpr uint16_t otype_glyf_flag_scaled_component_offset = 0x0800;
28constexpr uint16_t otype_glyf_flag_unscaled_component_offset = 0x1000;
30constexpr uint8_t otype_glyf_flag_on_curve = 0x01;
31constexpr uint8_t otype_glyf_flag_x_short = 0x02;
32constexpr uint8_t otype_glyf_flag_y_short = 0x04;
33constexpr uint8_t otype_glyf_flag_repeat = 0x08;
34constexpr uint8_t otype_glyf_flag_x_same = 0x10;
35constexpr uint8_t otype_glyf_flag_y_same = 0x20;
64 auto const num_contours = *
header.num_contours;
66 hi_check(num_contours >= 0,
"'glyph' path requested on a compound glyph.");
94 if (to_bool(
flag & detail::otype_glyf_flag_repeat)) {
107 auto const flag = flags[i];
109 if (to_bool(
flag & detail::otype_glyf_flag_x_short)) {
110 if (to_bool(
flag & detail::otype_glyf_flag_x_same)) {
117 if (to_bool(
flag & detail::otype_glyf_flag_x_same)) {
129 auto const flag = flags[i];
131 if (to_bool(
flag & detail::otype_glyf_flag_y_short)) {
132 if (to_bool(
flag & detail::otype_glyf_flag_y_same)) {
139 if (to_bool(
flag & detail::otype_glyf_flag_y_same)) {
153 auto const flag = flags[i];
158 to_bool(
flag & detail::otype_glyf_flag_on_curve) ? bezier_point::Type::Anchor : bezier_point::Type::QuadraticControl;
167 hi::glyph_id glyph_id = {};
203 hi_check(*
header.num_contours < 0,
"'glyph' compound requested on a simple glyph.");
212 if (to_bool(flags & detail::otype_glyf_flag_args_are_xy_values)) {
213 if (to_bool(flags & detail::otype_glyf_flag_arg1_and_arg2_are_words)) {
222 if (to_bool(flags & detail::otype_glyf_flag_arg1_and_arg2_are_words)) {
234 if (to_bool(flags & detail::otype_glyf_flag_has_scale)) {
237 }
else if (to_bool(flags & detail::otype_glyf_flag_has_xy_scale)) {
241 }
else if (to_bool(flags & detail::otype_glyf_flag_has_2x2)) {
246 if (to_bool(flags & detail::otype_glyf_flag_scaled_component_offset)) {
250 if (to_bool(flags & detail::otype_glyf_flag_use_this_glyph_metrics)) {
256 }
while (to_bool(flags & detail::otype_glyf_flag_more_components));
279 return *
header.num_contours < 0;
309 hi_check(x_min <= x_max,
"'glyf' bounding box is invalid.");
310 hi_check(y_min <= y_max,
"'glyf' bounding box is invalid.");
312 return aarectangle{point2{x_min, y_min}, point2{x_max, y_max}};
Defined font_char_map type.
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
The HikoGUI namespace.
Definition recursive_iterator.hpp:15
hi_inline aarectangle otype_glyf_get_bounding_box(std::span< std::byte const > bytes, float em_scale)
Get the bounding box of a simple glyph.
Definition otype_glyf.hpp:287
hi_inline graphic_path otype_glyf_get_path(std::span< std::byte const > bytes, float em_scale)
Get the graphic-path of a simple glyph.
Definition otype_glyf.hpp:53
hi_inline bool otype_glyf_is_compound(std::span< std::byte const > bytes)
Check if this glyph is a compound or simple glyph.
Definition otype_glyf.hpp:263
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:378
hi_inline generator< otype_glyf_component > otype_glyf_get_compound(std::span< std::byte const > bytes, float em_scale)
Get the components of a compound glyph.
Definition otype_glyf.hpp:193
Definition otype_glyf.hpp:37
Definition otype_glyf.hpp:166
bool use_points
The component is positioned using anchor points.
Definition otype_glyf.hpp:181
size_t component_point_index
The point in the current component being added to the compound.
Definition otype_glyf.hpp:177
bool use_for_metrics
Use this glyph for the metrics of the compound.
Definition otype_glyf.hpp:185
size_t compound_point_index
The point-nr in the compound being assembled.
Definition otype_glyf.hpp:173
Open-type for 16 signed integer that must be scaled by the EM-scale.
Definition otype_utilities.hpp:40
Class which represents an axis-aligned rectangle.
Definition aarectangle.hpp:33
A 2D or 3D homogenius matrix for transforming homogenious vectors and points.
Definition matrix2.hpp:39
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector2.hpp:26
A path is a vector graphics object.
Definition graphic_path.hpp:29