diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2023-10-11 14:31:53 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2023-10-11 14:31:53 +0000 |
| commit | 6e58bd835126c90d1bbd38edad3ef769068ca368 (patch) | |
| tree | 16ca700c8bb42ab78f141467c811fdf24107e0b5 /terminal.c | |
| parent | render: better description of why we disable transparency in fullscreen (diff) | |
| parent | term: cache font baseline (diff) | |
Merge branch 'fix-font-baseline-calculation'
Closes #1511
Closes #1463
Diffstat (limited to 'terminal.c')
| -rw-r--r-- | terminal.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -774,6 +774,8 @@ term_set_fonts(struct terminal *term, struct fcft_font *fonts[static 4], term->font_x_ofs = term_pt_or_px_as_pixels(term, &conf->horizontal_letter_offset); term->font_y_ofs = term_pt_or_px_as_pixels(term, &conf->vertical_letter_offset); + term->font_baseline = term_font_baseline(term); + LOG_INFO("cell width=%d, height=%d", term->cell_width, term->cell_height); sixel_cell_size_changed(term); @@ -2189,10 +2191,18 @@ 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 = max(font->height, font->ascent + font->descent); - const int glyph_top_y = round((line_height - font_height) / 2.); + const int font_height = font->ascent + font->descent; + + /* + * 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 + glyph_top_y + font->ascent; + return term->font_y_ofs + line_height - glyph_top_y - font->descent; } void |
