render: change baseline calculation, to center it within the line

Before this patch, fonts were anchored to the top of the line. With
this patch, it is instead centered.

Closes #1302
This commit is contained in:
Daniel Eklöf 2023-07-21 08:17:32 +02:00
parent 098f0aafd4
commit b3255465f1
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 9 additions and 1 deletions

View file

@ -305,7 +305,12 @@ color_brighten(const struct terminal *term, uint32_t color)
static inline int
font_baseline(const struct terminal *term)
{
return term->font_y_ofs + term->fonts[0]->ascent;
const struct fcft_font *font = term->fonts[0];
const int line_height = term->cell_height;
const int font_height = font->ascent + font->descent;
const int glyph_top_y = round((line_height - font_height) / 2.);
return term->font_y_ofs + glyph_top_y + font->ascent;
}
static void