diff options
Diffstat (limited to 'src/graphics')
-rw-r--r-- | src/graphics/font.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/graphics/font.c b/src/graphics/font.c index aa349a6..b6ceaf5 100644 --- a/src/graphics/font.c +++ b/src/graphics/font.c @@ -7,6 +7,7 @@ /* Need padding so filtering doesn't touch pixels in another glyphs area */ #define GLYPH_PADDING 2 #define GLYPH_UPSAMPLE 1 +#define GLYPH_SHIFT 0.5f int mgl_font_load_from_file(mgl_font *self, const mgl_memory_mapped_file *mapped_file, unsigned int character_size) { self->texture.id = 0; @@ -167,7 +168,7 @@ int mgl_font_get_glyph(mgl_font *self, uint32_t codepoint, mgl_font_glyph *glyph const float glyph_advance = font_scale * advance; int x0, y0, x1, y1; - stbtt_GetGlyphBitmapBox(self->font_info, glyph_index, font_scale, font_scale, &x0, &y0, &x1, &y1); + stbtt_GetGlyphBitmapBoxSubpixel(self->font_info, glyph_index, font_scale, font_scale, GLYPH_SHIFT, GLYPH_SHIFT, &x0, &y0, &x1, &y1); int width = x1 - x0; int height = y1 - y0; @@ -181,7 +182,7 @@ int mgl_font_get_glyph(mgl_font *self, uint32_t codepoint, mgl_font_glyph *glyph unsigned char *pixels = calloc(pixels_size, 1); if(pixels) { const int top_padding = GLYPH_PADDING; - stbtt_MakeGlyphBitmap(self->font_info, pixels + pixels_width * top_padding + GLYPH_PADDING, width, height, pixels_width, font_scale, font_scale, glyph_index); + stbtt_MakeGlyphBitmapSubpixel(self->font_info, pixels + pixels_width * top_padding + GLYPH_PADDING, width, height, pixels_width, font_scale, font_scale, GLYPH_SHIFT, GLYPH_SHIFT, glyph_index); } mgl_vec2i render_offset; |