22 std::optional<std::filesystem::path> _path;
30 uint16_t OS2_x_height = 0;
31 uint16_t OS2_cap_height = 0;
36 uint16_t numberOfHMetrics;
43 parse_font_directory();
46 true_type_font(std::filesystem::path
const& path) : _path(path), view(std::make_unique<file_view>(path))
48 ++global_counter<
"ttf:map">;
50 parse_font_directory();
54 ++global_counter<
"ttf:unmap">;
57 throw parse_error(std::format(
"{}: Could not parse font directory.\n{}", path.string(), e.
what()));
68 [[nodiscard]]
bool loaded() const noexcept
override
76 [[nodiscard]] hi::glyph_id
find_glyph(
char32_t c)
const noexcept override;
96 const noexcept override;
98 [[nodiscard]]
vector2 get_kerning(hi::glyph_id current_glyph, hi::glyph_id next_glyph)
const noexcept override;
101 const noexcept override
106 mutable std::span<std::byte const> _cmap_table_bytes;
107 mutable std::span<std::byte const> _cmap_bytes;
108 mutable std::span<std::byte const> _loca_table_bytes;
109 mutable std::span<std::byte const> _glyf_table_bytes;
110 mutable std::span<std::byte const> _hmtx_table_bytes;
111 mutable std::span<std::byte const> _kern_table_bytes;
112 mutable std::span<std::byte const> _GSUB_table_bytes;
113 bool _loca_table_is_offset32;
115 void cache_tables() const noexcept
117 _cmap_table_bytes = get_table_bytes(
"cmap");
118 _cmap_bytes = parse_cmap_table_directory();
119 _loca_table_bytes = get_table_bytes(
"loca");
120 _glyf_table_bytes = get_table_bytes(
"glyf");
121 _hmtx_table_bytes = get_table_bytes(
"hmtx");
124 _kern_table_bytes = get_table_bytes(
"kern");
125 _GSUB_table_bytes = get_table_bytes(
"GSUB");
128 void load_view() const noexcept
135 view = std::make_unique<file_view>(*_path);
136 ++global_counter<
"ttf:map">;
144 [[nodiscard]] std::span<std::byte const> get_table_bytes(
char const *table_name)
const;
151 void parse_font_directory();
153 void parse_head_table(std::span<std::byte const> headTableBytes);
154 void parse_hhea_table(std::span<std::byte const> bytes);
155 void parse_name_table(std::span<std::byte const> bytes);
156 void parse_OS2_table(std::span<std::byte const> bytes);
157 void parse_maxp_table(std::span<std::byte const> bytes);
159 [[nodiscard]] std::span<std::byte const> parse_cmap_table_directory()
const;
163 [[nodiscard]] hi::unicode_mask parse_cmap_table_mask()
const;
168 bool get_glyf_bytes(hi::glyph_id glyph_id, std::span<std::byte const> &bytes)
const noexcept;
173 bool update_glyph_metrics(
174 hi::glyph_id glyph_id,
175 glyph_metrics &metrics,
176 hi::glyph_id kern_glyph1_id = hi::glyph_id{},
177 hi::glyph_id kern_glyph2_id = hi::glyph_id{})
const noexcept;
179 bool load_simple_glyph(std::span<std::byte const> bytes, graphic_path &glyph)
const noexcept;
190 load_compound_glyph(std::span<std::byte const> bytes, graphic_path &glyph, hi::glyph_id &metrics_glyph_id)
const noexcept;
199 bool load_compound_glyph_metrics(std::span<std::byte const> bytes, hi::glyph_id &metrics_glyph_id)
const noexcept;
207 [[nodiscard]]
std::ptrdiff_t get_coverage_index(std::span<std::byte const> bytes, hi::glyph_id glyph)
noexcept;
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:100