From 436986d18289d0507786442423bf09a1d74dde41 Mon Sep 17 00:00:00 2001 From: Quantum Date: Fri, 23 Jul 2021 00:22:04 -0400 Subject: [PATCH] [client] imgui: make UI font and size configurable --- client/include/util.h | 1 - client/src/config.c | 16 ++++++++++++++++ client/src/main.c | 4 ++-- client/src/main.h | 2 ++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/client/include/util.h b/client/include/util.h index 8936ee85..a58c80c9 100644 --- a/client/include/util.h +++ b/client/include/util.h @@ -46,7 +46,6 @@ static inline double util_clamp(double x, double min, double max) return x; } -#define DEFAULT_FONT_NAME "DejaVu Sans Mono" char * util_getUIFont(const char * fontName); #endif diff --git a/client/src/config.c b/client/src/config.c index 4617e323..a4471620 100644 --- a/client/src/config.c +++ b/client/src/config.c @@ -262,6 +262,20 @@ static struct Option options[] = .validator = optRotateValidate, .value.x_int = 0, }, + { + .module = "win", + .name = "uiFont", + .description = "The font to use when rendering on-screen UI", + .type = OPTION_TYPE_STRING, + .value.x_string = "DejaVu Sans Mono", + }, + { + .module = "win", + .name = "uiSize", + .description = "The font size to use when rendering on-screen UI", + .type = OPTION_TYPE_INT, + .value.x_int = 14 + }, // input options { @@ -526,6 +540,8 @@ bool config_load(int argc, char * argv[]) g_params.autoScreensaver = option_get_bool ("win", "autoScreensaver"); g_params.showAlerts = option_get_bool ("win", "alerts" ); g_params.quickSplash = option_get_bool ("win", "quickSplash" ); + g_params.uiFont = option_get_string("win" , "uiFont" ); + g_params.uiSize = option_get_int ("win" , "uiSize" ); if (g_params.noScreensaver && g_params.autoScreensaver) { diff --git a/client/src/main.c b/client/src/main.c index e67dfadc..33fcd033 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -191,7 +191,7 @@ static int renderThread(void * unused) ImFontAtlas_Clear(g_state.io->Fonts); ImFontAtlas_AddFontFromFileTTF(g_state.io->Fonts, g_state.fontName, - 14 * g_state.windowScale, NULL, NULL); + g_params.uiSize * g_state.windowScale, NULL, NULL); ImFontAtlas_Build(g_state.io->Fonts); if (g_state.lgr) @@ -770,7 +770,7 @@ static int lg_run(void) &text_w, &text_h, NULL); g_state.windowScale = 1.0; - g_state.fontName = util_getUIFont(DEFAULT_FONT_NAME); + g_state.fontName = util_getUIFont(g_params.uiFont); DEBUG_INFO("Using font: %s", g_state.fontName); g_state.overlays = ll_new(); diff --git a/client/src/main.h b/client/src/main.h index 34994671..aaa8861d 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -154,6 +154,8 @@ struct AppParams bool quickSplash; bool alwaysShowCursor; uint64_t helpMenuDelayUs; + const char * uiFont; + int uiSize; unsigned int cursorPollInterval; unsigned int framePollInterval;