diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2022-11-23 15:15:32 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2022-11-23 15:29:42 +0000 |
| commit | 5a54423000ad0cffec0178a6091c87d75110eee0 (patch) | |
| tree | 66515be1a17f0550a19eef5c7b76cdb390ac7e92 | |
| parent | readme/foot.1: mention that we now need “-d info” to get log output (diff) | |
term: adjust user-set line-height by the same percentage as the primary font
Before this patch, a user-set line-height was increased/decreased by
the exact same amount of pt’s as the font(s).
This means, that when there’s a large discrepancy between the
line-height and the font size, the proportion between the line’s
height and the font size will change as we increase or decrease the
font size.
This patch changes how the line height is adjusted when the font size
is incremented or decremented. We calculate the difference, in
percent, between the primary font’s original (default) size, and its
current size, and then apply that to the configured line-height.
Closes #1218
| -rw-r--r-- | terminal.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -2031,12 +2031,20 @@ term_font_size_adjust(struct terminal *term, double amount) } if (term->font_line_height.px >= 0) { - float old_pt_size = term->font_line_height.px > 0 - ? term->font_line_height.px * 72. / dpi - : term->font_line_height.pt; + const struct config *conf = term->conf; + + const float font_original_pt_size = + conf->fonts[0].arr[0].px_size > 0 + ? conf->fonts[0].arr[0].px_size * 72. / dpi + : conf->fonts[0].arr[0].pt_size; + + const float change = term->font_sizes[0][0].pt_size / font_original_pt_size; + const float line_original_pt_size = conf->line_height.px > 0 + ? conf->line_height.px * 72. / dpi + : conf->line_height.pt; term->font_line_height.px = 0; - term->font_line_height.pt = fmaxf(old_pt_size + amount, 0.); + term->font_line_height.pt = fmaxf(line_original_pt_size * change, 0.); } return reload_fonts(term); |
