HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
font_grapheme_id.hpp
1// Copyright Take Vos 2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "../unicode/grapheme.hpp"
8#include "../hash.hpp"
9
10namespace hi::inline v1 {
11
15 hi::font const *font;
16 grapheme g;
17
18 font_grapheme_id(hi::font const &font, grapheme g) noexcept : font(&font), g(std::move(g)) {}
19
20 [[nodiscard]] std::size_t hash() const noexcept
21 {
22 hi_axiom(font);
23 return hash_mix(reinterpret_cast<ptrdiff_t>(font), g);
24 }
25
26 [[nodiscard]] friend bool operator==(font_grapheme_id const &lhs, font_grapheme_id const &rhs) noexcept
27 {
28 hi_axiom(lhs.font and rhs.font);
29 return (lhs.font == rhs.font) and (lhs.g == rhs.g);
30 }
31};
32
33} // namespace hi::inline v1
34
35template<>
36struct std::hash<hi::font_grapheme_id> {
37 [[nodiscard]] std::size_t operator()(hi::font_grapheme_id const &rhs) const noexcept
38 {
39 return rhs.hash();
40 }
41};
Definition font.hpp:34
Combined font_id + grapheme for use as a key in a std::unordered_map.
Definition font_grapheme_id.hpp:14
A grapheme, what a user thinks a character is.
Definition grapheme.hpp:34
T move(T... args)
T operator()(T... args)