#ifndef MGL_FONT_H #define MGL_FONT_H #include "../system/fileutils.h" #include "font_char_map.h" #include "texture.h" #include 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; int initial_section_height; int right_section_height; } mgl_font_atlas; struct mgl_font { /* Font texture coordinates are in pixel space. Note: the texture id may change */ mgl_texture texture; mgl_font_atlas font_atlas; unsigned int character_size; int ascent; int descent; int linegap; int max_glyph_height; 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 */