From 128c5c3efabc212f74a73ce256f8b35ee3ca49a5 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 20 Apr 2024 08:18:41 +0200 Subject: term: default to DPI 96, if the monitor's DPI is 0 This can happen in virtualized environments, or when running a nested Wayland session. --- terminal.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index c027cfac..b684030e 100644 --- a/terminal.c +++ b/terminal.c @@ -878,10 +878,13 @@ get_font_dpi(const struct terminal *term) mon = &tll_front(term->wl->monitors); } - if (term_fractional_scaling(term)) - return mon != NULL ? mon->dpi.physical : 96.; - else - return mon != NULL ? mon->dpi.scaled : 96.; + const float monitor_dpi = mon != NULL + ? term_fractional_scaling(term) + ? mon->dpi.physical + : mon->dpi.scaled + : 96.; + + return monitor_dpi > 0. ? monitor_dpi : 96.; } static enum fcft_subpixel -- cgit v1.3