7#include "glyph_metrics.hpp"
8#include "glyph_atlas_info.hpp"
9#include "glyph_ids.hpp"
10#include "font_weight.hpp"
11#include "font_variant.hpp"
12#include "font_metrics.hpp"
13#include "../unicode/unicode_mask.hpp"
14#include "../unicode/gstring.hpp"
15#include "../i18n/iso_15924.hpp"
16#include "../i18n/iso_639.hpp"
17#include "../graphic_path.hpp"
18#include "../resource_view.hpp"
19#include "../exception.hpp"
22#include "../hash_map.hpp"
28namespace hi::inline v1 {
48 bool monospace =
false;
51 bool condensed =
false;
52 font_weight weight = font_weight::Regular;
53 float optical_size = 12.0;
73 virtual ~font() =
default;
75 font &operator=(
font const &) =
delete;
83 [[nodiscard]]
virtual bool loaded() const noexcept = 0;
88 [[nodiscard]] virtual hi::
glyph_id find_glyph(
char32_t c) const noexcept = 0;
112 virtual
bool load_glyph_metrics(
123 [[nodiscard]]
virtual vector2 get_kerning(hi::glyph_id current_glyph, hi::glyph_id next_glyph)
const noexcept = 0;
155 if (glyphs.has_num_glyphs<1>()) [[likely]] {
157 if (index >= _single_glyph_atlas_table.size()) [[unlikely]] {
158 _single_glyph_atlas_table.resize(index + 1);
160 return _single_glyph_atlas_table[index];
163 return _multi_glyph_atlas_table[glyphs];
169 return {weight, italic};
175 "{} - {}: style={}{}{}{}{}{}, features={}",
178 rhs.monospace ?
'M' :
'_',
179 rhs.serif ?
'S' :
'_',
180 rhs.italic ?
'I' :
'_',
181 rhs.condensed ?
'C' :
'_',
189 mutable hash_map<glyph_ids, glyph_atlas_info> _multi_glyph_atlas_table;
194template<
typename CharT>
195struct std::formatter<hi::font, CharT> : formatter<std::string_view, CharT> {
196 auto format(hi::font
const &t,
auto &fc)
198 return formatter<string_view, CharT>::format(
to_string(t), fc);
This file includes required definitions.
#define hilet
Invariant should be the default for variables.
Definition required.hpp:23
A path is a vector graphics object.
Definition graphic_path.hpp:29
ISO-15924 script code.
Definition iso_15924.hpp:18
ISO-639 language code.
Definition iso_639.hpp:25
Definition language.hpp:18
virtual bool loaded() const noexcept=0
Return if the font is loaded.
hi::font_metrics metrics
The metrics of a font.
Definition font.hpp:66
virtual vector2 get_kerning(hi::glyph_id current_glyph, hi::glyph_id next_glyph) const noexcept=0
Get the kerning between two glyphs.
std::string features
A string representing the features of a font.
Definition font.hpp:58
virtual void substitution_and_kerning(iso_639 language, iso_15924 script, std::vector< substitution_and_kerning_type > &word) const noexcept=0
Substitute and kern a run of glyphs.
std::string family_name
The family name as parsed from the font file.
Definition font.hpp:40
std::string sub_family_name
The sub-family name as parsed from the font file.
Definition font.hpp:46
std::vector< hi::font * > fallback_chain
List of fonts to use as a fallback for this font.
Definition font.hpp:70
vector2 advance
The advance in font-unit coordinate system.
Definition font.hpp:141
glyph_id glyph
The glyph.
Definition font.hpp:132
A font variant is one of 16 different fonts that can be part of a family.
Definition font_variant.hpp:16
Definition glyph_atlas_info.hpp:12
A set of glyph-ids of a font which composites into a single glyph.
Definition glyph_ids.hpp:127
Definition glyph_metrics.hpp:17
A grapheme, what a user thinks a character is.
Definition grapheme.hpp:34
A mask of unicode code-points.
Definition unicode_mask.hpp:101