From 34aa979f460c09a481a02af733737a5925c9b1bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 10 Oct 2023 13:52:24 +0200 Subject: [PATCH] term_font_baseline(): only center glyph when a custom line-height is being used When using the font's own line-height, simply set the baseline 'descent' pixels above the bottom of the cell. This fixes an issue where some fonts appeared "glued" to the top of the cell, and sometimes getting partially clipped. --- terminal.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/terminal.c b/terminal.c index dd92cd67..e517253b 100644 --- a/terminal.c +++ b/terminal.c @@ -2190,9 +2190,17 @@ term_font_baseline(const struct terminal *term) 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; + /* + * Center glyph on the line *if* using a custom line height, + * otherwise the baseline is simply 'descent' pixels above the + * bottom of the cell + */ + const int glyph_top_y = term->font_line_height.px >= 0 + ? round((line_height - font_height) / 2.) + : 0; + + return term->font_y_ofs + line_height - glyph_top_y - font->descent; } void