mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
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
This commit is contained in:
parent
dfabc5d754
commit
5a54423000
1 changed files with 12 additions and 4 deletions
16
terminal.c
16
terminal.c
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue