aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/Font.h
blob: d805d1c40cc8c3fb5256723edeaadf1936dd944f (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
#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 graphics
{  

    class Font: public Drawable
    {
    public: 
        Font(); 
        void loadFile(const char* file); 
        void loadMemory(const unsigned char* data);
        void render(
            const char* text, // rendered text 
            float x, float y, // render position 
            int fondSize,     // font size 
            int spacing,      // font spacing 
            int lineHeight    // line height
        );
        void box(const char* text, int fontHeight, int spacing, int lineHeight, int* w, int * h); 

    private: 
        /* ASCII 32(space)..126(~) 95 glyphs */
        static const int ASCII_CHARACTER_NUM = 96;

        stbtt_bakedchar asciiData[ASCII_CHARACTER_NUM];
        
    };

} // graphics
} // jin

#endif // JIN_MODULES_RENDER
#endif // __JIN_FONT_H