-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleFonts.h
More file actions
54 lines (39 loc) · 1.28 KB
/
Copy pathModuleFonts.h
File metadata and controls
54 lines (39 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef __MODULE_FONTS_H__
#define __MODULE_FONTS_H__
#include "Module.h"
#include "SDL\include\SDL_pixels.h"
#define MAX_FONTS 10
#define MAX_FONT_CHARS 256
struct SDL_Texture;
struct Font {
// Lookup table. All characters displayed in the same order as the texture
char table[MAX_FONT_CHARS];
// The font texture
SDL_Texture* texture = nullptr;
// Font setup data
uint totalLength;
uint rows, columns;
uint char_w, char_h;
};
class ModuleFonts : public Module {
public:
// Constructor
ModuleFonts(Application* app, bool start_enabled = true);
// Destructor
~ModuleFonts();
// Loads a font file from a texture
// Returns a font index from the fonts array
// Param texturePath - The path to the texture file
// Param characters - The lookup table. All characters displayed in the same order as the texture
// Param rows - The amount of character rows in the texture
int Load(const char* texturePath, const char* characters, uint rows = 1);
// Removes a font by its index
// Unloads the texture and removes it from the fonts array
void Unload(int fontIndex);
// Create a surface from text
void BlitText(int x, int y, int fontIndex, const char* text) const;
private:
// An array to keep track and store all loaded fonts
Font fonts[MAX_FONTS];
};
#endif // __ModuleFonts_H__