21 std::optional<URL> url;
29 uint16_t OS2_x_height = 0;
30 uint16_t OS2_cap_height = 0;
35 uint16_t numberOfHMetrics;
42 parse_font_directory();
47 ++global_counter<
"ttf:map">;
49 parse_font_directory();
53 ++global_counter<
"ttf:unmap">;
56 throw parse_error(std::format(
"{}: Could not parse font directory.\n{}", to_string(url), e.
what()));
67 [[nodiscard]]
bool loaded() const noexcept
override
75 [[nodiscard]] hi::glyph_id
find_glyph(
char32_t c)
const noexcept override;
95 const noexcept override;
97 [[nodiscard]]
vector2 get_kerning(hi::glyph_id current_glyph, hi::glyph_id next_glyph)
const noexcept override;
100 const noexcept override
105 mutable std::span<std::byte const> _cmap_table_bytes;
106 mutable std::span<std::byte const> _cmap_bytes;
107 mutable std::span<std::byte const> _loca_table_bytes;
108 mutable std::span<std::byte const> _glyf_table_bytes;
109 mutable std::span<std::byte const> _hmtx_table_bytes;
110 mutable std::span<std::byte const> _kern_table_bytes;
111 mutable std::span<std::byte const> _GSUB_table_bytes;
112 bool _loca_table_is_offset32;
114 void cache_tables() const noexcept
116 _cmap_table_bytes = get_table_bytes(
"cmap");
117 _cmap_bytes = parse_cmap_table_directory();
118 _loca_table_bytes = get_table_bytes(
"loca");
119 _glyf_table_bytes = get_table_bytes(
"glyf");
120 _hmtx_table_bytes = get_table_bytes(
"hmtx");
123 _kern_table_bytes = get_table_bytes(
"kern");
124 _GSUB_table_bytes = get_table_bytes(
"GSUB");
127 void load_view() const noexcept
134 view = url->loadView();
135 ++global_counter<
"ttf:map">;
143 [[nodiscard]] std::span<std::byte const> get_table_bytes(
char const *table_name)
const;
150 void parse_font_directory();
152 void parse_head_table(std::span<std::byte const> headTableBytes);
153 void parse_hhea_table(std::span<std::byte const> bytes);
154 void parse_name_table(std::span<std::byte const> bytes);
155 void parse_OS2_table(std::span<std::byte const> bytes);
156 void parse_maxp_table(std::span<std::byte const> bytes);
158 [[nodiscard]] std::span<std::byte const> parse_cmap_table_directory()
const;
162 [[nodiscard]] hi::unicode_mask parse_cmap_table_mask()
const;
167 bool get_glyf_bytes(hi::glyph_id glyph_id, std::span<std::byte const> &bytes)
const noexcept;
172 bool update_glyph_metrics(
173 hi::glyph_id glyph_id,
174 glyph_metrics &metrics,
175 hi::glyph_id kern_glyph1_id = hi::glyph_id{},
176 hi::glyph_id kern_glyph2_id = hi::glyph_id{})
const noexcept;
178 bool load_simple_glyph(std::span<std::byte const> bytes, graphic_path &glyph)
const noexcept;
189 load_compound_glyph(std::span<std::byte const> bytes, graphic_path &glyph, hi::glyph_id &metrics_glyph_id)
const noexcept;
198 bool load_compound_glyph_metrics(std::span<std::byte const> bytes, hi::glyph_id &metrics_glyph_id)
const noexcept;
206 [[nodiscard]]
std::ptrdiff_t get_coverage_index(std::span<std::byte const> bytes, hi::glyph_id glyph)
noexcept;
bool load_glyph_metrics(hi::glyph_id glyph_id, glyph_metrics &metrics, hi::glyph_id lookahead_glyph_id=hi::glyph_id{}) const noexcept override
Load a glyphMetrics into a path.
virtual void substitution_and_kerning(iso_639 language, iso_15924 script, std::vector< substitution_and_kerning_type > &word) const noexcept override
Substitute and kern a run of glyphs.
Definition true_type_font.hpp:99