blob: 4bd0428e6059d22750fc80439877d7acf84e9174 (
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
|
#ifndef MGL_FONT_H
#define MGL_FONT_H
#include "../system/fileutils.h"
#include "font_char_map.h"
#include "texture.h"
#include <stdint.h>
typedef struct mgl_memory_mapped_file mgl_memory_mapped_file;
typedef struct mgl_font mgl_font;
typedef enum {
MGL_ATLAS_SECTION_INITIAL,
MGL_ATLAS_SECTION_RIGHT,
MGL_ATLAS_SECTION_BOTTOM
} mgl_font_atlas_render_section;
typedef struct {
int width;
int height;
int prev_width;
int prev_height;
mgl_vec2i pointer_position;
mgl_font_atlas_render_section render_section;
} mgl_font_atlas;
struct mgl_font {
mgl_texture texture; /* Font texture coordinates are in pixel space */
mgl_font_atlas font_atlas;
unsigned int character_size;
mgl_font_char_map char_map;
int current_line_max_height;
void *font_info;
};
int mgl_font_load_from_file(mgl_font *self, const mgl_memory_mapped_file *mapped_file, unsigned int character_size);
void mgl_font_unload(mgl_font *self);
/* Note: loads the glyph if it hasn't been loaded yet */
int mgl_font_get_glyph(mgl_font *self, uint32_t codepoint, mgl_font_glyph *glyph);
/* Returns the kerning */
float mgl_font_get_kerning(const mgl_font *self, uint32_t prev_codepoint, uint32_t codepoint);
#endif /* MGL_FONT_H */
|