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
9typedef void* NW_FT_Lib ;
10typedef void* NW_FT_Face;
11typedef std::string FontIdentifier;
12
16class Glyph {
17public:
18 Glyph() = default;
19
23 void Delete();
24
25 uint32 advance = 0;
29};
30
34class Font : public Asset {
35private:
36 NW_FT_Face face = nullptr;
37public:
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
Defines the GameObject class and its related components.
The base class for all assets.
Definition Asset.h:9
Class representing a font asset.
Definition Font.h:34
static void Destroy()
Destroys the FreeType library.
Definition Font.cpp:13
void Clean() override
Clean up the asset.
Definition Font.cpp:76
std::unordered_map< char, Glyph > charactersMap
Definition Font.h:38
Asset * LoadFromFile(const char *path, void *data) override
Load the asset from file based on the file path.
Definition Font.cpp:27
Asset * GetFromCache(void *identifier) override
Get the asset from the cache based on the identifier.
Definition Font.cpp:19
Asset * LoadFromBuffer(void *ftFace, void *data) override
Load the asset from a buffer.
Definition Font.cpp:37
static bool Init()
Initializes the FreeType library.
Definition Font.cpp:9
bool LoadFont(std::string path)
Loads a font from a file.
static NW_FT_Lib lib
Definition Font.h:55
Class representing a game object.
Definition GameObject.h:68
Class representing a glyph.
Definition Font.h:16
uint32 advance
Definition Font.h:25
void Delete()
Deletes the glyph.
Definition Font.cpp:72
iVec2 bearing
Definition Font.h:26
Texture texture
Definition Font.h:28
iVec2 size
Definition Font.h:27
Class representing a texture asset.
Definition Texture.h:81
Struct representing a character.
Definition Font.h:74
Glyph * glyph
Definition Font.h:75
GameObject go
Definition Font.h:76