diff options
Diffstat (limited to 'include/mgl/graphics/font.h')
-rw-r--r-- | include/mgl/graphics/font.h | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/include/mgl/graphics/font.h b/include/mgl/graphics/font.h index c4904ff..adcc8a7 100644 --- a/include/mgl/graphics/font.h +++ b/include/mgl/graphics/font.h @@ -1,37 +1,45 @@ #ifndef MGL_FONT_H #define MGL_FONT_H -#include "../system/vec.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 struct { - mgl_vec2f position; - mgl_vec2f size; - mgl_vec2f texture_position; - mgl_vec2f texture_size; - float advance; -} mgl_font_glyph; +typedef enum { + MGL_ATLAS_SECTION_INITIAL, + MGL_ATLAS_SECTION_RIGHT, + MGL_ATLAS_SECTION_BOTTOM +} mgl_font_atlas_render_section; typedef struct { - unsigned char *atlas; 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; mgl_font_atlas font_atlas; unsigned int character_size; - void *packed_chars; - uint32_t num_packed_chars; + mgl_font_char_map char_map; + int current_line_max_height; + void *font_info; }; -int mgl_font_load_from_file(mgl_font *self, const char *filepath, unsigned int character_size); +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); -int mgl_font_get_glyph(const mgl_font *self, uint32_t codepoint, mgl_font_glyph *glyph); +/* 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 */ +int mgl_font_get_kerning(const mgl_font *self, uint32_t prev_codepoint, uint32_t codepoint); #endif /* MGL_FONT_H */ |