22 true_type_font(std::filesystem::path
const& path) : _path(path), _view(file_view{path})
24 ++global_counter<
"ttf:map">;
26 _bytes = as_span<std::byte const>(_view);
27 parse_font_directory(_bytes);
32 ++global_counter<
"ttf:unmap">;
35 throw parse_error(std::format(
"{}: Could not parse font directory.\n{}", path.string(), e.
what()));
46 [[nodiscard]]
bool loaded() const noexcept
override
48 return to_bool(_view);
59 std::filesystem::path _path;
65 mutable file_view _view;
67 float OS2_x_height = 0;
68 float OS2_cap_height = 0;
72 uint16_t _num_horizontal_metrics;
75 mutable std::span<std::byte const> _bytes;
76 mutable std::span<std::byte const> _loca_table_bytes;
77 mutable std::span<std::byte const> _glyf_table_bytes;
78 mutable std::span<std::byte const> _hmtx_table_bytes;
79 mutable std::span<std::byte const> _kern_table_bytes;
80 mutable std::span<std::byte const> _GSUB_table_bytes;
81 bool _loca_is_offset32;
83 void cache_tables(std::span<std::byte const> bytes)
const
85 _loca_table_bytes = otype_sfnt_search<
"loca">(bytes);
86 _glyf_table_bytes = otype_sfnt_search<
"glyf">(bytes);
87 _hmtx_table_bytes = otype_sfnt_search<
"hmtx">(bytes);
90 _kern_table_bytes = otype_sfnt_search<
"kern">(bytes);
91 _GSUB_table_bytes = otype_sfnt_search<
"GSUB">(bytes);
94 void load_view() const noexcept
100 _view = file_view{_path};
101 _bytes = as_span<std::byte const>(_view);
102 ++global_counter<
"ttf:map">;
103 cache_tables(_bytes);
111 void parse_font_directory(std::span<std::byte const> bytes);
119 [[nodiscard]]
std::ptrdiff_t get_coverage_index(std::span<std::byte const> bytes, hi::glyph_id glyph);
123 [[nodiscard]] font::shape_run_result_type shape_run_basic(gstring run)
const;
125 void shape_run_kern(font::shape_run_result_type &shape_result)
const;