From e10cc19f66f17f68db13873bbda677b4d6c20aff Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 18 Sep 2023 05:56:46 +0300 Subject: [PATCH 23/23] sdl2: Make size 13 fonts to adjust to theme font size Some clean up made, as this replaces the last direct use of adj_font() See osdn #48641 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/chatline.c | 12 ++++++------ client/gui-sdl2/gui_string.c | 12 +++++++++++- client/gui-sdl2/gui_string.h | 16 ++++------------ 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/client/gui-sdl2/chatline.c b/client/gui-sdl2/chatline.c index eb4bab0d5d..0dc77eb568 100644 --- a/client/gui-sdl2/chatline.c +++ b/client/gui-sdl2/chatline.c @@ -183,7 +183,7 @@ static void popup_load_game_dialog(void) return; } - /* disable buttons */ + /* Disable buttons */ set_wstate(conn_dlg->back_button, FC_WS_DISABLED); widget_redraw(conn_dlg->back_button); widget_mark_dirty(conn_dlg->back_button); @@ -240,12 +240,12 @@ static void popup_load_game_dialog(void) fileinfo_list_iterate(files, pfile) { count++; - filename = create_utf8_from_char(pfile->name, adj_font(13)); + filename = create_utf8_from_char_fonto(pfile->name, FONTO_ATTENTION_PLUS); filename->style |= SF_CENTER; filename_label = create_iconlabel(NULL, pwindow->dst, filename, (WF_FREE_DATA | WF_SELECT_WITHOUT_BAR | WF_RESTORE_BACKGROUND)); - /* store filename */ + /* Store filename */ filename_label->data.ptr = fc_calloc(1, strlen(pfile->fullname) + 1); fc_strlcpy((char*)filename_label->data.ptr, pfile->fullname, strlen(pfile->fullname) + 1); @@ -254,7 +254,7 @@ static void popup_load_game_dialog(void) set_wstate(filename_label, FC_WS_NORMAL); - /* FIXME: this was supposed to be add_widget_to_vertical_scroll_widget_list(), but + /* FIXME: This was supposed to be add_widget_to_vertical_scroll_widget_list(), but * add_widget_to_vertical_scroll_widget_list() needs the scrollbar area to be defined * for updating the scrollbar position, but the area is not known yet (depends on * maximum label width) */ @@ -289,7 +289,7 @@ static void popup_load_game_dialog(void) area.y + 1, area.h - adj_size(2), TRUE); - /* add filename labels to list */ + /* Add filename labels to list */ filename_label = first_label; while (filename_label) { filename_label->size.w = area.w - scrollbar_width - 3; @@ -327,7 +327,7 @@ static void popup_load_game_dialog(void) area.x + area.w - close_button->size.w - 1, pwindow->size.y + adj_size(2)); - /* FIXME: the scrollbar already got a background saved in + /* FIXME: The scrollbar already got a background saved in * add_widget_to_vertical_scroll_widget_list(), but the window * is not drawn yet, so this saved background is wrong. * Deleting it here as a workaround. */ diff --git a/client/gui-sdl2/gui_string.c b/client/gui-sdl2/gui_string.c index 142c5a7299..914e9d35ae 100644 --- a/client/gui-sdl2/gui_string.c +++ b/client/gui-sdl2/gui_string.c @@ -60,13 +60,20 @@ 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); +/* Adjust font sizes on 320x240 screen */ +#ifdef SMALL_SCREEN + static int adj_font(int size); +#else /* SMALL_SCREEN */ + #define adj_font(size) size +#endif /* SMALL_SCREEN */ + #define ptsize_default() adj_font(default_font_size(active_theme)) /**********************************************************************//** Adjust font sizes for small screen. **************************************************************************/ #ifdef SMALL_SCREEN -int adj_font(int size) +static int adj_font(int size) { switch (size) { case 24: @@ -172,6 +179,9 @@ static Uint16 fonto_ptsize(enum font_origin origin) case FONTO_ATTENTION: def = ptsize_default(); return adj_font(MAX(def + 1, def * 1.2)); + case FONTO_ATTENTION_PLUS: + def = ptsize_default(); + return adj_font(MAX(def + 1, def * 1.2)); /* Same as FONTO_ATTENTION, when def < 10 */ case FONTO_HEADING: def = ptsize_default(); return adj_font(MAX(def + 2, def * 1.4)); diff --git a/client/gui-sdl2/gui_string.h b/client/gui-sdl2/gui_string.h index 8cf99f9a1d..910d525a1f 100644 --- a/client/gui-sdl2/gui_string.h +++ b/client/gui-sdl2/gui_string.h @@ -64,6 +64,7 @@ enum font_origin { FONTO_DEFAULT, FONTO_SLIGHTLY_BIGGER, FONTO_ATTENTION, + FONTO_ATTENTION_PLUS, FONTO_HEADING, FONTO_BIG, FONTO_MAX @@ -73,10 +74,8 @@ utf8_str *create_utf8_str_fonto(char *in_text, size_t n_alloc, enum font_origin origin); utf8_str *create_utf8_str(char *in_text, size_t n_alloc, Uint16 ptsize); utf8_str *copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars); -bool convert_utf8_str_to_const_surface_width(utf8_str *pstr, - int width); -int write_utf8(SDL_Surface *dest, Sint16 x, Sint16 y, - utf8_str *pstr); +bool convert_utf8_str_to_const_surface_width(utf8_str *pstr, int width); +int write_utf8(SDL_Surface *dest, Sint16 x, Sint16 y, utf8_str *pstr); SDL_Surface *create_text_surf_from_utf8(utf8_str *pstr); SDL_Surface *create_text_surf_smaller_than_w(utf8_str *pstr, int w); void utf8_str_size(utf8_str *pstr, SDL_Rect *fill); @@ -86,15 +85,8 @@ void change_fonto_utf8(utf8_str *pstr, enum font_origin origin); void unload_font(Uint16 ptsize); void free_font_system(void); -/* adjust font sizes on 320x240 screen */ -#ifdef SMALL_SCREEN - int adj_font(int size); -#else - #define adj_font(size) size -#endif - /* - * here we use ordinary free( ... ) because check is made + * Here we use ordinary free( ... ) because check is made * on start. */ #define FREEUTF8STR( pstr ) \ -- 2.40.1