7#include "otype_utilities.hpp"
8#include "../utility/utility.hpp"
9#include "../macros.hpp"
13hi_export_module(hikogui.font.otype_htmx);
15hi_export
namespace hi {
inline namespace v1 {
17[[nodiscard]]
inline auto
18otype_hmtx_get(std::span<std::byte const> bytes, hi::glyph_id glyph_id, uint16_t num_horizontal_metrics,
float em_scale)
21 otype_fuword_buf_t advance_width;
22 otype_fword_buf_t left_side_bearing;
27 float left_side_bearing;
30 hi_axiom(num_horizontal_metrics >= 1);
33 auto const horizontal_metrics = implicit_cast<entry_type>(offset, bytes, num_horizontal_metrics);
35 if (*glyph_id < num_horizontal_metrics) {
36 auto const& entry = horizontal_metrics[*glyph_id];
37 return return_type{entry.advance_width * em_scale, entry.left_side_bearing * em_scale};
41 auto const advance_width = horizontal_metrics.back().advance_width * em_scale;
44 auto const num_left_side_bearing = (bytes.size() - offset) /
sizeof(otype_fword_buf_t);
45 auto const left_side_bearings = implicit_cast<otype_fword_buf_t>(offset, bytes, num_left_side_bearing);
47 auto const left_side_bearing_index = *glyph_id - num_horizontal_metrics;
48 auto const left_side_bearing = hi_check_at(left_side_bearings, left_side_bearing_index) * em_scale;
49 return return_type{advance_width, left_side_bearing};
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20