aboutsummaryrefslogtreecommitdiff
path: root/include/mglpp/graphics/Font.hpp
blob: afba8d3a8e67a1360c5ced0a7f5bc4305c146e20 (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 MGLPP_FONT_HPP
#define MGLPP_FONT_HPP

#include "../system/vec.hpp"

extern "C" {
#include <mgl/graphics/font.h>
}

namespace mgl {
    class Texture;
    class MemoryMappedFile;

    struct FontGlyph {
        vec2i position;
        vec2i size;
        vec2i texture_position; /* In pixel space */
        vec2i texture_size; /* In pixel space */
        float advance = 0.0f;
    };

    class Font {
    public:
        Font();
        Font(const Font&) = delete;
        Font& operator=(const Font&) = delete;
        ~Font();

        bool load_from_file(const MemoryMappedFile &mapped_file, unsigned int character_size);
        unsigned int get_character_size() const;
        // Returns 0 sized glyph if the font doesn't have the codepoint
        FontGlyph get_glyph(uint32_t codepoint);
        float get_kerning(uint32_t prev_codepoint, uint32_t codepoint);

        Texture get_texture() const;
        mgl_font* internal_font();
    private:
        mgl_font font;
    };
}

#endif /* MGLPP_FONT_HPP */