diff options
Diffstat (limited to 'src/graphics/font.c')
-rw-r--r-- | src/graphics/font.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/graphics/font.c b/src/graphics/font.c index 8344a04..2ed54d2 100644 --- a/src/graphics/font.c +++ b/src/graphics/font.c @@ -47,8 +47,8 @@ int mgl_font_load_from_file(mgl_font *self, const char *filepath, unsigned int c /* 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->character_size; - self->font_atlas.height = (8 + (8 * i)) * self->character_size; + self->font_atlas.width = (14 + (8 * i)) * self->character_size; + self->font_atlas.height = (14 + (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,6 +67,8 @@ int mgl_font_load_from_file(mgl_font *self, const char *filepath, unsigned int c return -1; } + stbtt_PackSetOversampling(&pc, 2, 2); + if(!stbtt_PackFontRange(&pc, filedata.data, 0, self->character_size, 0, self->num_packed_chars, self->packed_chars)) { stbtt_PackEnd(&pc); continue; @@ -92,7 +94,6 @@ int mgl_font_load_from_file(mgl_font *self, const char *filepath, unsigned int c } /* TODO: Use stbtt_GetCodepointSDF */ - /* TODO: Use stbtt_PackSetOversampling */ mgl_filedata_free(&filedata); return 0; @@ -119,7 +120,7 @@ int mgl_font_get_glyph(const mgl_font *self, uint32_t codepoint, mgl_font_glyph float x = 0.0f; float y = 0.0f; stbtt_aligned_quad quad; - stbtt_GetPackedQuad(packed_chars, self->font_atlas.width, self->font_atlas.height, codepoint, &x, &y, &quad, 1); + stbtt_GetPackedQuad(packed_chars, self->font_atlas.width, self->font_atlas.height, codepoint, &x, &y, &quad, 0); glyph->position = (mgl_vec2f){ quad.x0, quad.y0 }; glyph->size = (mgl_vec2f){ quad.x1 - quad.x0, quad.y1 - quad.y0 }; |