From 9da3c2188060dc982412d7a6e1cd2051b9ddb6a6 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 19 Oct 2021 22:12:52 +0200 Subject: Change from callback to window poll --- src/graphics/font.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/graphics/font.c') diff --git a/src/graphics/font.c b/src/graphics/font.c index 20d9dfa..f55144a 100644 --- a/src/graphics/font.c +++ b/src/graphics/font.c @@ -10,14 +10,14 @@ /* TODO: Test and fix .tcc files */ -int mgl_font_load_from_file(mgl_font *self, const char *filepath, unsigned int font_size) { +int mgl_font_load_from_file(mgl_font *self, const char *filepath, unsigned int character_size) { self->texture.id = 0; self->font_atlas.atlas = NULL; self->font_atlas.width = 0; self->font_atlas.height = 0; - self->size = font_size; + self->character_size = character_size; self->packed_chars = NULL; self->num_packed_chars = 0; @@ -47,8 +47,8 @@ int mgl_font_load_from_file(mgl_font *self, const char *filepath, unsigned int f /* TODO: Optimize */ /* Find optimal size for atlas, starting from small to large */ for(int i = 0; i < 4; ++i) { - self->font_atlas.width = (8 + (8 * i)) * self->size; - self->font_atlas.height = (8 + (8 * i)) * self->size; + self->font_atlas.width = (8 + (8 * i)) * self->character_size; + self->font_atlas.height = (8 + (8 * i)) * self->character_size; unsigned char *new_atlas = realloc(self->font_atlas.atlas, self->font_atlas.width * self->font_atlas.height); if(!new_atlas) { fprintf(stderr, "Error: failed to load font %s, error: out of memory\n", filepath); @@ -67,7 +67,7 @@ int mgl_font_load_from_file(mgl_font *self, const char *filepath, unsigned int f return -1; } - if(!stbtt_PackFontRange(&pc, filedata.data, 0, self->size, 0, self->num_packed_chars, self->packed_chars)) { + if(!stbtt_PackFontRange(&pc, filedata.data, 0, self->character_size, 0, self->num_packed_chars, self->packed_chars)) { stbtt_PackEnd(&pc); continue; } @@ -84,7 +84,7 @@ int mgl_font_load_from_file(mgl_font *self, const char *filepath, unsigned int f return -1; } - if(mgl_texture_load_from_memory(&self->texture, self->font_atlas.atlas, self->font_atlas.width, self->font_atlas.height, MGL_TEXTURE_ALPHA, NULL) != 0) { + if(mgl_texture_load_from_memory(&self->texture, self->font_atlas.atlas, self->font_atlas.width, self->font_atlas.height, MGL_IMAGE_FORMAT_ALPHA, NULL) != 0) { fprintf(stderr, "Error: failed to load font %s, error: mgl_texture_load_from_memory failed\n", filepath); mgl_filedata_free(&filedata); mgl_font_unload(self); -- cgit v1.2.3