From 8734a7c764b580b039c5ecd3d8caf55c9b68ac89 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Fri, 12 May 2023 22:53:43 +0300
Subject: [PATCH 25/25] sdl2: Fix changing font size to the default one

See osdn #48037

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 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 57d93e8e8b..f40c6c256e 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(active_theme))
+
 /**********************************************************************//**
   Adjust font sizes for small screen.
 **************************************************************************/
@@ -179,13 +181,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(active_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;
@@ -529,6 +531,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 c45855710d..a61e21c9fd 100644
--- a/client/gui-sdl2/mapview.c
+++ b/client/gui-sdl2/mapview.c
@@ -548,7 +548,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