From a098fad004f70a52c2b3163e185d95e8abcf2704 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 14 Dec 2021 17:45:12 +0100 Subject: term: font_size_adjust: use DPI=96 when font is *not* scaled by DPI Closes #842 --- terminal.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index d5728a53..73f003d6 100644 --- a/terminal.c +++ b/terminal.c @@ -1917,11 +1917,13 @@ term_font_size_adjust(struct terminal *term, double amount) { const struct config *conf = term->conf; + const float dpi = term->font_is_sized_by_dpi ? term->font_dpi : 96.; + for (size_t i = 0; i < 4; i++) { const struct config_font_list *font_list = &conf->fonts[i]; for (size_t j = 0; j < font_list->count; j++) { - double old_pt_size = term->font_sizes[i][j].pt_size; + float old_pt_size = term->font_sizes[i][j].pt_size; /* * To ensure primary and user-configured fallback fonts are @@ -1929,23 +1931,21 @@ term_font_size_adjust(struct terminal *term, double amount) * sizes, and to the adjustment on point sizes only. */ - if (term->font_sizes[i][j].px_size > 0) { - double dpi = term->font_dpi; + if (term->font_sizes[i][j].px_size > 0) old_pt_size = term->font_sizes[i][j].px_size * 72. / dpi; - } - term->font_sizes[i][j].pt_size = fmax(old_pt_size + amount, 0); + term->font_sizes[i][j].pt_size = fmaxf(old_pt_size + amount, 0.); term->font_sizes[i][j].px_size = -1; } } if (term->font_line_height.px >= 0) { - double old_pt_size = term->font_line_height.px > 0 - ? term->font_line_height.px * 72. / term->font_dpi + float old_pt_size = term->font_line_height.px > 0 + ? term->font_line_height.px * 72. / dpi : term->font_line_height.pt; term->font_line_height.px = 0; - term->font_line_height.pt = fmax(old_pt_size + amount, 0); + term->font_line_height.pt = fmaxf(old_pt_size + amount, 0.); } return reload_fonts(term); -- cgit v1.3