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.
This commit is contained in:
Daniel Eklöf 2023-10-10 13:52:24 +02:00
parent 7d126ff414
commit 34aa979f46
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -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