From 9921af54d093f3f2572ed1b929785ef60ad45216 Mon Sep 17 00:00:00 2001 From: mintsuki Date: Thu, 27 Jul 2023 01:41:32 -0500 Subject: [PATCH] gterm: Autoscale font on higher resolutions --- common/lib/gterm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/common/lib/gterm.c b/common/lib/gterm.c index 2078fd99..ad2fd795 100644 --- a/common/lib/gterm.c +++ b/common/lib/gterm.c @@ -740,6 +740,7 @@ no_load_font:; size_t font_scale_x = 1; size_t font_scale_y = 1; + bool font_scale_is_default = true; char *menu_font_scale = config_get_value(config, 0, "TERM_FONT_SCALE"); if (menu_font_scale != NULL) { @@ -747,6 +748,8 @@ no_load_font:; if (font_scale_x > 8 || font_scale_y > 8) { font_scale_x = 1; font_scale_y = 1; + } else { + font_scale_is_default = false; } } @@ -782,6 +785,17 @@ no_load_font:; generate_canvas(fb); + if (font_scale_is_default) { + if (fb->framebuffer_width > 1366 && fb->framebuffer_height > 768) { + font_scale_x = 2; + font_scale_y = 2; + } + if (fb->framebuffer_width > 2560 && fb->framebuffer_height > 1440) { + font_scale_x = 4; + font_scale_y = 4; + } + } + terms[terms_i] = flanterm_fb_init(ext_mem_alloc, pmm_free, (void *)(uintptr_t)fb->framebuffer_addr,