NWengine
0.9
Loading...
Searching...
No Matches
Font.h
1
#pragma once
2
#include <string>
3
#include <unordered_map>
4
5
#include "
GameObject.h
"
6
#include "Texture.h"
7
#include "Asset.h"
8
9
typedef
void
* NW_FT_Lib ;
10
typedef
void
* NW_FT_Face;
11
typedef
std::string FontIdentifier;
12
16
class
Glyph
{
17
public
:
18
Glyph
() =
default
;
19
23
void
Delete
();
24
25
uint32
advance
= 0;
26
iVec2
bearing
;
27
iVec2
size
;
28
Texture
texture
;
29
};
30
34
class
Font
:
public
Asset
{
35
private
:
36
NW_FT_Face face =
nullptr
;
37
public
:
38
std::unordered_map<char, Glyph>
charactersMap
;
40
Font
() =
default
;
41
47
bool
LoadFont
(std::string path);
48
49
void
Clean
()
override
;
50
51
Asset
*
GetFromCache
(
void
* identifier)
override
;
52
Asset
*
LoadFromFile
(
const
char
* path,
void
* data)
override
;
53
Asset
*
LoadFromBuffer
(
void
* ftFace,
void
* data)
override
;
54
55
static
NW_FT_Lib
lib
;
61
static
bool
Init
();
62
66
static
void
Destroy
();
67
68
NW_DECL_RES_LIST(FontIdentifier,
Font
);
69
};
70
74
struct
Character
{
75
Glyph
*
glyph
;
76
GameObject
go
;
77
};
GameObject.h
Defines the GameObject class and its related components.
Asset
The base class for all assets.
Definition
Asset.h:9
Font
Class representing a font asset.
Definition
Font.h:34
Font::Destroy
static void Destroy()
Destroys the FreeType library.
Definition
Font.cpp:13
Font::Clean
void Clean() override
Clean up the asset.
Definition
Font.cpp:76
Font::charactersMap
std::unordered_map< char, Glyph > charactersMap
Definition
Font.h:38
Font::LoadFromFile
Asset * LoadFromFile(const char *path, void *data) override
Load the asset from file based on the file path.
Definition
Font.cpp:27
Font::GetFromCache
Asset * GetFromCache(void *identifier) override
Get the asset from the cache based on the identifier.
Definition
Font.cpp:19
Font::LoadFromBuffer
Asset * LoadFromBuffer(void *ftFace, void *data) override
Load the asset from a buffer.
Definition
Font.cpp:37
Font::Init
static bool Init()
Initializes the FreeType library.
Definition
Font.cpp:9
Font::LoadFont
bool LoadFont(std::string path)
Loads a font from a file.
Font::lib
static NW_FT_Lib lib
Definition
Font.h:55
GameObject
Class representing a game object.
Definition
GameObject.h:68
Glyph
Class representing a glyph.
Definition
Font.h:16
Glyph::advance
uint32 advance
Definition
Font.h:25
Glyph::Delete
void Delete()
Deletes the glyph.
Definition
Font.cpp:72
Glyph::bearing
iVec2 bearing
Definition
Font.h:26
Glyph::texture
Texture texture
Definition
Font.h:28
Glyph::size
iVec2 size
Definition
Font.h:27
Texture
Class representing a texture asset.
Definition
Texture.h:81
Vector2< int >
Character
Struct representing a character.
Definition
Font.h:74
Character::glyph
Glyph * glyph
Definition
Font.h:75
Character::go
GameObject go
Definition
Font.h:76
Graphics
Font.h
Generated by
1.10.0