summaryrefslogtreecommitdiffstats
path: root/src/ttf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ttf.c')
-rw-r--r--src/ttf.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/ttf.c b/src/ttf.c
index 9cfaab0..2bc24cf 100644
--- a/src/ttf.c
+++ b/src/ttf.c
@@ -28,6 +28,7 @@ mf_ttf_render(TTF_Font *font, const char *text, SDL_Color *color,
{
SDL_Surface *surface;
SDL_Texture *texture;
+ int line_skip;
int ascent;
int max_y;
const char *c;
@@ -46,10 +47,12 @@ mf_ttf_render(TTF_Font *font, const char *text, SDL_Color *color,
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Couldn't create texture: %s",
SDL_GetError());
+ SDL_FreeSurface(surface);
return NULL;
}
- ascent = TTF_FontAscent(font);
+ line_skip = TTF_FontLineSkip(font);
+ ascent = TTF_FontAscent (font);
max_y = 0;
for (c = text; *c != '\0'; ++c) {
if (TTF_GlyphMetrics(font, *c, NULL, NULL, NULL, &glyph_max_y,
@@ -64,7 +67,7 @@ mf_ttf_render(TTF_Font *font, const char *text, SDL_Color *color,
}
}
rect->x = 0;
- rect->y = ascent - max_y;
+ rect->y = (line_skip - ascent) / 2 + (ascent - max_y);
rect->w = surface->w;
rect->h = surface->h;