8#include "font_family_id.hpp"
9#include "elusive_icon.hpp"
10#include "hikogui_icon.hpp"
11#include "../unicode/module.hpp"
12#include "../geometry/module.hpp"
13#include "../utility/module.hpp"
14#include "../generator.hpp"
21namespace hi::inline
v1 {
40 return font->get_metrics(glyph);
43 [[nodiscard]] aarectangle get_bounding_rectangle()
const noexcept
45 return get_metrics().bounding_rectangle;
51 lean_vector<glyph_id> glyphs;
54 static font_book& global() noexcept;
57 font_book(font_book const&) = delete;
58 font_book(font_book&&) = delete;
59 font_book& operator=(font_book const&) = delete;
60 font_book& operator=(font_book&&) = delete;
91 [[nodiscard]] font_family_id
find_family(
std::
string const& family_name) const noexcept;
138 inline static
std::unique_ptr<font_book> _global =
nullptr;
142 std::unordered_map<
std::
string, font_family_id> _family_names;
151 [[nodiscard]]
std::vector<
hi::
font *> make_fallback_chain(
font_weight weight, font_style style) noexcept;
166 return font_book::global().register_font_file(path);
169inline void register_font_directory(std::filesystem::path
const& path)
171 return font_book::global().register_font_directory(path);
174template<
typename Range>
175inline void register_font_directories(Range&& range)
noexcept
177 for (
auto const& path : range) {
178 font_book::global().register_font_directory(path,
false);
180 font_book::global().post_process();
188 return font_book::global().find_family(family_name);
200 return font_book::global().find_font(family_id, variant);
212 return font_book::global().find_font(family_name, variant);
238 return font_book::global().find_glyph(
font, code_point);
241[[nodiscard]]
inline auto find_glyph(elusive_icon rhs)
noexcept
243 hilet *font = find_font(
"elusiveicons", font_variant{font_weight::medium, font_style::normal});
248[[nodiscard]]
inline auto find_glyph(hikogui_icon rhs)
noexcept
250 hilet *font =
find_font(
"Hikogui Icons", font_variant{font_weight::regular, font_style::normal});
#define hi_assert_not_null(x,...)
Assert if an expression is not nullptr.
Definition assert.hpp:238
#define hi_axiom_not_null(expression,...)
Assert if an expression is not nullptr.
Definition assert.hpp:272
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:13
font_weight
Definition font_weight.hpp:17
auto find_glyph(font const &font, grapheme grapheme) noexcept
Find a glyph using the given code-point.
Definition font_book.hpp:223
font & register_font_file(std::filesystem::path const &path)
Register a font.
Definition font_book.hpp:164
font const & find_font(font_family_id family_id, font_variant variant=font_variant{}) noexcept
Find a font closest to the variant.
Definition font_book.hpp:198
font_family_id find_font_family(std::string const &family_name) noexcept
Find font family id.
Definition font_book.hpp:186
geometry/margins.hpp
Definition cache.hpp:11
void post_process() noexcept
Post process font_book Should be called after a set of register_font() calls This calculates font fal...
void register_font_directory(std::filesystem::path const &path, bool post_process=true)
Register all fonts found in a directory.
font const & find_font(font_family_id family_id, font_variant variant) const noexcept
Find a font closest to the variant.
font_family_id register_family(std::string_view family_name) noexcept
Register font family id.
font & register_font_file(std::filesystem::path const &path, bool post_process=true)
Register a font.
font_glyphs_type find_glyph(font const &font, grapheme grapheme) const noexcept
Find a glyph using the given code-point.
font_family_id find_family(std::string const &family_name) const noexcept
Find font family id.
Definition font_book.hpp:31
Definition font_book.hpp:49
A font variant is one of 16 different fonts that can be part of a family.
Definition font_variant.hpp:17
Definition glyph_metrics.hpp:16
A grapheme-cluster, what a user thinks a character is.
Definition grapheme.hpp:42