Skip to content

Commit

Permalink
gterm: Autoscale font on higher resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
mintsuki committed Jul 27, 2023
1 parent 16b5e75 commit 71ba012
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions common/lib/gterm.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,13 +740,16 @@ 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) {
parse_resolution(&font_scale_x, &font_scale_y, NULL, menu_font_scale);
if (font_scale_x > 8 || font_scale_y > 8) {
font_scale_x = 1;
font_scale_y = 1;
} else {
font_scale_is_default = false;
}
}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 71ba012

Please sign in to comment.