aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/Font.h
blob: 0ab482da1272bdb9f8d10379d89aa4e0f757ba77 (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
#ifndef __LIBJIN_FONT_H
#define __LIBJIN_FONT_H
#include "../modules.h"
#if LIBJIN_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 * createFont(const char* file);
        Font* createFont(const char* data, size_t size);

        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;

        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
        );

        stbtt_bakedchar asciiData[ASCII_CHARACTER_NUM];
                        
    };

} // graphics
} // jin

#endif // LIBJIN_MODULES_RENDER
#endif // __LIBJIN_FONT_H