aboutsummaryrefslogtreecommitdiff
path: root/include/mgl/graphics/font.h
blob: 6aa918813e6cb8211920962a587ea25e93f45d57 (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
#ifndef MGL_FONT_H
#define MGL_FONT_H

#include "../system/vec.h"
#include "texture.h"
#include <stdint.h>

typedef struct mgl_font mgl_font;

typedef struct {
    mgl_vec2f position;
    mgl_vec2f size;
    mgl_vec2f texture_position;
    mgl_vec2f texture_size;
    float advance;
} mgl_font_glyph;

typedef struct {
    unsigned char *atlas;
    int width;
    int height;
} mgl_font_atlas;

struct mgl_font {
    mgl_texture texture;
    mgl_font_atlas font_atlas;
    unsigned int character_size;
    void *packed_chars;
    uint32_t num_packed_chars;
};

int mgl_font_load_from_file(mgl_font *self, const char *filepath, unsigned int character_size);
void mgl_font_unload(mgl_font *self);

int mgl_font_get_glyph(mgl_font *self, uint32_t codepoint, mgl_font_glyph *glyph);

#endif /* MGL_FONT_H */