blob: cde64b5b64d3ad271a13a0f0fb122a5b54a5d961 (
plain)
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
59
60
61
|
#ifndef __JIN_FONT_H
#define __JIN_FONT_H
#include "../modules.h"
#if JIN_MODULES_RENDER
#include "drawable.h"
#include "3rdparty/stb/stb_truetype.h"
#include "../math/quad.h"
namespace jin
{
namespace render
{
/**
* Usage of stb_truetype.h here might be a little
* bit dummy. Implementation of Font is referring
* to stb_truetype.h L243~284. I basicly copy it:)
*/
class Font: public Drawable
{
public:
Font();
/**
* load ttf font data from .ttf
*/
void loadf(const char* file);
/**
* load ttf font data from memory
*/
void loadb(const unsigned char* data);
/**
* render text to screen
*/
void render(
const char* str, // rendered text
float x, float y, // render position
int fheight, // font size
int spacing, // font spacing
int lheight // line height
);
void box(const char* str, int fheight, int spacing, int lheight, int* w, int * h);
private:
/**
* ASCII 32(space)..126(~) is 95 glyphs
*/
stbtt_bakedchar cdata[96];
};
}
}
#endif // JIN_MODULES_RENDER
#endif // __JIN_FONT_H
|