#ifndef MGL_FONT_CHAR_MAP_H #define MGL_FONT_CHAR_MAP_H #include "font_glyph.h" #include #include #include typedef struct mgl_font_char_entry mgl_font_char_entry; typedef struct mgl_font_char_map mgl_font_char_map; struct mgl_font_char_entry { uint32_t key; mgl_font_glyph value; mgl_font_char_entry *next; /* TODO: Remove when fonts copy textures */ mgl_vec2i render_offset; /* TODO: Remove when fonts copy textures */ bool rendered; }; typedef struct { mgl_font_char_map *char_map; size_t index; mgl_font_char_entry *value; } mgl_font_char_iterator; struct mgl_font_char_map { mgl_font_char_entry **entries; size_t size; size_t capacity; }; void mgl_font_char_map_init(mgl_font_char_map *self); void mgl_font_char_map_deinit(mgl_font_char_map *self); /* |value| is copied. |inserted_entry| is the newly allocated and inserted entry. the entry wont ever reallocate. may be set to NULL to ignore it. */ int mgl_font_char_map_insert(mgl_font_char_map *self, uint32_t key, const mgl_font_glyph *value, mgl_font_char_entry **inserted_entry); /* The returned value is only valid until the next insert */ mgl_font_char_entry* mgl_font_char_map_get(const mgl_font_char_map *self, uint32_t key); void mgl_font_char_map_clear_rendered(mgl_font_char_map *self); /* Iterator value is NULL when the end has been reached */ mgl_font_char_iterator mgl_font_char_map_begin(mgl_font_char_map *self); void mgl_font_char_iterator_next(mgl_font_char_iterator *self); #endif /* MGL_FONT_CHAR_MAP_H */