gterm: Autoscale font on higher resolutions

This commit is contained in:
mintsuki 2023-07-27 01:41:32 -05:00
parent a2e502328d
commit 9921af54d0
1 changed files with 14 additions and 0 deletions

View File

@ -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,