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 "../exception.hpp"
20#include "../hash_map.hpp"
26namespace hi::inline
v1 {
46 bool monospace =
false;
49 bool condensed =
false;
51 float optical_size = 12.0;
71 virtual ~font() =
default;
73 font &operator=(
font const &) =
delete;
81 [[nodiscard]]
virtual bool loaded() const noexcept = 0;
86 [[nodiscard]] virtual
hi::
glyph_id find_glyph(
char32_t c) const noexcept = 0;
110 virtual
bool load_glyph_metrics(
121 [[nodiscard]]
virtual vector2 get_kerning(hi::glyph_id current_glyph, hi::glyph_id next_glyph)
const noexcept = 0;
153 if (glyphs.has_num_glyphs<1>()) [[likely]] {
155 if (index >= _single_glyph_atlas_table.size()) [[unlikely]] {
156 _single_glyph_atlas_table.resize(index + 1);
158 return _single_glyph_atlas_table[index];
161 return _multi_glyph_atlas_table[glyphs];
167 return {weight, italic};
173 "{} - {}: style={}{}{}{}{}{}, features={}",
176 rhs.monospace ?
'M' :
'_',
177 rhs.serif ?
'S' :
'_',
178 rhs.italic ?
'I' :
'_',
179 rhs.condensed ?
'C' :
'_',
187 mutable hash_map<glyph_ids, glyph_atlas_info> _multi_glyph_atlas_table;
192template<
typename CharT>
193struct std::formatter<
hi::font, CharT> : formatter<std::string_view, CharT> {
194 auto format(hi::font
const &t,
auto &fc)
196 return formatter<string_view, CharT>::format(
to_string(t), fc);
Utilities used by the HikoGUI library itself.
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:15
font_weight
Definition font_weight.hpp:17
The HikoGUI namespace.
Definition ascii.hpp:19
A path is a vector graphics object.
Definition graphic_path.hpp:29
ISO-15924 script code.
Definition iso_15924.hpp:19
ISO-639 language code.
Definition iso_639.hpp:25
Definition language.hpp:17
virtual bool loaded() const noexcept=0
Return if the font is loaded.
hi::font_metrics metrics
The metrics of a font.
Definition font.hpp:64
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:56
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:38
std::string sub_family_name
The sub-family name as parsed from the font file.
Definition font.hpp:44
std::vector< hi::font * > fallback_chain
List of fonts to use as a fallback for this font.
Definition font.hpp:68
vector2 advance
The advance in font-unit coordinate system.
Definition font.hpp:139
glyph_id glyph
The glyph.
Definition font.hpp:130
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:15
A set of glyph-ids of a font which composites into a single glyph.
Definition glyph_ids.hpp:135
Definition glyph_metrics.hpp:17
A grapheme-cluster, what a user thinks a character is.
Definition grapheme.hpp:41
A mask of unicode code-points.
Definition unicode_mask.hpp:101