LkEngine
0.1.2
Loading...
Searching...
No Matches
Font.h
1
#pragma once
2
3
#include "
LkEngine/Core/CoreMacros.h
"
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
14
namespace
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
36
struct
FFontConfiguration
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
46
struct
FFontEntry
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
76
namespace
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
CoreMacros.h
Core macros used by the entire engine.
LkEngine
Definition
Asset.h:11
std
Definition
UUID.h:33
LkEngine::FFontConfiguration
Definition
Font.h:37
LkEngine::FFontEntry
Definition
Font.h:47
std::hash
Definition
UUID.h:35
LkEngine
Source
LkEngine
Renderer
UI
Font.h
Generated by
1.12.0