aboutsummaryrefslogtreecommitdiff
path: root/include/mgl/graphics/font.h
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-10-16 19:36:53 +0200
committerdec05eba <dec05eba@protonmail.com>2021-10-16 19:46:05 +0200
commit046b2b7a38ec66208c96be59c030294b6d10351b (patch)
tree5858b113d026c47cdae0c47033eaa0bbe9f0d113 /include/mgl/graphics/font.h
parent5cbff06ff9153f7a7958202a777d98ebeae59393 (diff)
Add font rendering
Diffstat (limited to 'include/mgl/graphics/font.h')
-rw-r--r--include/mgl/graphics/font.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/include/mgl/graphics/font.h b/include/mgl/graphics/font.h
new file mode 100644
index 0000000..470662a
--- /dev/null
+++ b/include/mgl/graphics/font.h
@@ -0,0 +1,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 size;
+ void *packed_chars;
+ uint32_t num_packed_chars;
+};
+
+int mgl_font_load_from_file(mgl_font *self, const char *filepath, unsigned int font_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 */