From 475fe5078099c8906b6e3f7a360a258df7410410 Mon Sep 17 00:00:00 2001 From: rxi Date: Tue, 27 Sep 2016 19:45:45 +0100 Subject: [PATCH] Added rounding on font height / yoffset when initing font --- src/font.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/font.c b/src/font.c index 4d5b4ad..5f157be 100644 --- a/src/font.c +++ b/src/font.c @@ -28,7 +28,7 @@ static const char *initFont(font_t *self, const void *data, int ptsize) { int ascent, descent, lineGap; stbtt_GetFontVMetrics(&font, &ascent, &descent, &lineGap); float scale = stbtt_ScaleForMappingEmToPixels(&font, ptsize); - self->height = (ascent - descent + lineGap) * scale; + self->height = (ascent - descent + lineGap) * scale + 0.5; /* Init image */ int w = 128, h = 128; @@ -50,7 +50,7 @@ retry: } /* Adjust glyph yoffsets */ - int scaledAscent = ascent * scale; + int scaledAscent = ascent * scale + 0.5; for (i = 0; i < 128; i++) { self->glyphs[i].yoff += scaledAscent; }