mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
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:
parent
7d126ff414
commit
34aa979f46
1 changed files with 10 additions and 2 deletions
12
terminal.c
12
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue