From 4e68dad205c4b8ce52898a178254604eb60ab9a9 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 1 Apr 2023 06:09:01 +0300 Subject: [PATCH 10/10] sdl2: Adjust theme font size relative to other elements See osdn #47681 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/gui_string.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/client/gui-sdl2/gui_string.c b/client/gui-sdl2/gui_string.c index 23586ae8b5..14a7ec36fe 100644 --- a/client/gui-sdl2/gui_string.c +++ b/client/gui-sdl2/gui_string.c @@ -153,16 +153,18 @@ void utf8_str_size(utf8_str *pstr, SDL_Rect *fill) } /************************************************************************** - Create utf8_str struct with ptsize font. + Create utf8_str struct with ptsize font. If ptsize is zero, + use theme's default font size. + Font will be loaded or aliased with existing font of that size. - in_text must be allocated in memory (malloc/fc_calloc) + in_text must be allocated in memory (malloc() / fc_calloc()) **************************************************************************/ utf8_str *create_utf8_str(char *in_text, size_t n_alloc, Uint16 ptsize) { utf8_str *str = fc_calloc(1, sizeof(utf8_str)); - if (!ptsize) { - str->ptsize = theme_default_font_size(theme); + if (ptsize == 0) { + str->ptsize = adj_font(theme_default_font_size(theme)); } else { str->ptsize = ptsize; } @@ -179,7 +181,7 @@ utf8_str *create_utf8_str(char *in_text, size_t n_alloc, Uint16 ptsize) str->fgcol = *get_theme_color(COLOR_THEME_TEXT); str->render = 2; - /* in_text must be allocated in memory (malloc/fc_calloc) */ + /* in_text must be allocated in memory (fc_malloc() / fc_calloc() ) */ str->text = in_text; str->n_alloc = n_alloc; -- 2.39.2