LkEngine 0.1.2
 
Loading...
Searching...
No Matches
Font.h
1#pragma once
2
4
5#include <string>
6#include <string_view>
7
8#include <imgui/imgui.h>
9#include <imgui/imgui_internal.h>
10
11/* Use newer font registration system with changes to sizes. */
12//#define LK_UI_FONT_REWORKED
13
14namespace LkEngine {
15
16 enum class EFontSize
17 {
18 Regular = 0,
19 Smaller,
20 Small,
21 Large,
22 Larger,
23 Title,
24 Header,
25 };
26
27 extern const std::unordered_map<EFontSize, float> FontSizeMap;
28
29 enum class EFont
30 {
31 Default = 0,
32 SourceSansPro,
33 Roboto,
34 };
35
37 {
38 std::string FontName{};
39 std::filesystem::path FilePath{};
40 float Size = 18.0f;
41
42 bool MergeWithLast = false;
43 const ImWchar* GlyphRanges = nullptr;
44 };
45
47 {
48 std::string Name{};
49 float Size = 0.0f;
50 std::string FilePath{};
51
52 bool operator==(const FFontEntry& Other) const
53 {
54 return (Name == Other.Name);
55 }
56 };
57
64 namespace UI::Font
65 {
66 void Add(const FFontConfiguration& FontConfig, bool IsDefault = false);
67 void Push(const std::string& FontName);
68 void Pop();
69 ImFont* Get(const std::string& FontName);
70
71 std::size_t GetRegistered(std::vector<FFontEntry>& InFonts);
72 }
73
74}
75
76namespace std
77{
78 template<>
79 struct hash<LkEngine::FFontEntry>
80 {
81 std::size_t operator()(const LkEngine::FFontEntry& Entry) const noexcept
82 {
83 std::size_t Hash = 0;
84 for (const char Character : Entry.Name)
85 {
86 /* Common hash multiplier. */
87 #if defined(LK_UI_FONT_REWORKED)
88 Hash = (Hash * 31 + static_cast<unsigned char>(Character));
89 Hash += Entry.Size;
90 #else
91 Hash = (Hash * 31 + static_cast<unsigned char>(Character));
92 #endif
93 }
94
95 return Hash;
96 }
97 };
98}
99
Core macros used by the entire engine.
Definition Asset.h:11
Definition UUID.h:33
Definition Font.h:37
Definition Font.h:47
Definition UUID.h:35