From 4f0a23e44ab2c76268dec4c69447b020cf9462c2 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 12 May 2023 23:00:50 +0300 Subject: [PATCH 17/17] sdl2: Fix changing font size to the default one See osdn #48037 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/gui_string.c | 10 ++++++++-- client/gui-sdl2/mapview.c | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/client/gui-sdl2/gui_string.c b/client/gui-sdl2/gui_string.c index 372235f67c..64ec56d616 100644 --- a/client/gui-sdl2/gui_string.c +++ b/client/gui-sdl2/gui_string.c @@ -60,6 +60,8 @@ static TTF_Font *load_font(Uint16 ptsize); static SDL_Surface *create_utf8_surf(utf8_str *pstr); static SDL_Surface *create_utf8_multi_surf(utf8_str *pstr); +#define ptsize_default() adj_font(theme_default_font_size(theme)) + /************************************************************************** Adjust font sizes for small screen. **************************************************************************/ @@ -178,13 +180,13 @@ 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 == 0) { - str->ptsize = adj_font(theme_default_font_size(theme)); + str->ptsize = ptsize_default(); } else { str->ptsize = ptsize; } if ((str->font = load_font(str->ptsize)) == NULL) { - log_error("create_utf8_str(): load_font failed"); + log_error("create_utf8_str(): load_font() failed"); FC_FREE(str); return NULL; @@ -527,6 +529,10 @@ void change_ptsize_utf8(utf8_str *pstr, Uint16 new_ptsize) { TTF_Font *buf; + if (new_ptsize == 0) { + new_ptsize = ptsize_default(); + } + if (pstr->ptsize == new_ptsize) { return; } diff --git a/client/gui-sdl2/mapview.c b/client/gui-sdl2/mapview.c index c215e35125..e9b5a9ddfc 100644 --- a/client/gui-sdl2/mapview.c +++ b/client/gui-sdl2/mapview.c @@ -543,7 +543,7 @@ void redraw_unit_info_label(struct unit_list *punitlist) struct tile *pTile = unit_tile(pUnit); const char *vetname; - /* get and draw unit name (with veteran status) */ + /* Get and draw unit name (with veteran status) */ pstr = create_utf8_from_char(unit_name_translation(pUnit), adj_font(12)); pstr->style |= TTF_STYLE_BOLD; pstr->bgcol = (SDL_Color) {0, 0, 0, 0}; -- 2.39.2