From ae7adbf46720466526b31d968b4b2d5bfb977805 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 18 Sep 2023 05:51:17 +0300 Subject: [PATCH 27/27] 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 | 14 +++----------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/client/gui-sdl2/chatline.c b/client/gui-sdl2/chatline.c index 5a32e9869f..75f2452459 100644 --- a/client/gui-sdl2/chatline.c +++ b/client/gui-sdl2/chatline.c @@ -184,7 +184,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); @@ -241,12 +241,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); @@ -255,7 +255,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) */ @@ -290,7 +290,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; @@ -328,7 +328,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 bcc72f6155..31eadb3f7c 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 GUI_SDL2_SMALL_SCREEN + static int adj_font(int size); +#else /* GUI_SDL2_SMALL_SCREEN */ + #define adj_font(size) size +#endif /* GUI_SDL2_SMALL_SCREEN */ + #define ptsize_default() adj_font(default_font_size(active_theme)) /**********************************************************************//** Adjust font sizes for small screen. **************************************************************************/ #ifdef GUI_SDL2_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 d1844d1592..ac16a4875a 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,13 +85,6 @@ 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 GUI_SDL2_SMALL_SCREEN - int adj_font(int size); -#else - #define adj_font(size) size -#endif - /* * Here we use ordinary free( ... ) because check is made * on start. -- 2.40.1