diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2023-10-10 11:52:24 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2023-10-10 11:52:24 +0000 |
| commit | 34aa979f460c09a481a02af733737a5925c9b1bf (patch) | |
| tree | e8b7a59f11d7dbbf97f3cae16290c22f8bac3e2c | |
| parent | changelog: fixed font baseline calculation (diff) | |
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.
| -rw-r--r-- | terminal.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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 |
