-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfont.h
58 lines (45 loc) · 1.54 KB
/
font.h
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
55
56
57
58
#pragma once
#include <stdint.h>
#include "core.h"
namespace Pixie
{
class Window;
// BMP font loader. Expects the entire character set (256 ASCII characters) on one line.
class Font
{
public:
Font();
~Font();
// Loads the font in the given BMP filename using the specified character size.
bool Load(const char* filename, int characterSizeX, int characterSizeY);
// Draws the specified font to the window in the font colour.
void Draw(const char* msg, int x, int y, Pixie::Window* window);
// Draws the specified font to the window in the given colour.
void DrawColour(const char* msg, int x, int y, uint32_t colour, Pixie::Window* window);
// Returns the width of the specified string in this font.
int GetStringWidth(const char* msg) const;
// Returns the character height of the font.
int GetCharacterHeight() const;
// Returns the character width of the font.
int GetCharacterWidth() const;
private:
uint32_t* m_fontBuffer;
uint32_t m_width;
uint32_t m_height;
uint8_t m_characterSizeX;
uint8_t m_characterSizeY;
};
inline Font::Font()
{
m_fontBuffer = 0;
m_width = m_height = 0;
}
inline int Font::GetCharacterHeight() const
{
return m_characterSizeY;
}
inline int Font::GetCharacterWidth() const
{
return m_characterSizeX;
}
}