From fb84ba0abe16cfa2b22ce8f3e49518ddf2281918 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 17 Sep 2023 05:38:03 +0300 Subject: [PATCH 25/25] sdl2: Make size 24 fonts to adjust to theme font size See osdn #48629 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/dialogs.c | 6 +++--- client/gui-sdl2/gui_string.c | 3 +++ client/gui-sdl2/gui_string.h | 3 ++- client/gui-sdl2/helpdlg.c | 29 ++++++++++++++++------------- client/gui-sdl2/mapctrl.c | 4 ++-- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/client/gui-sdl2/dialogs.c b/client/gui-sdl2/dialogs.c index ad21eb596d..4fd1fef204 100644 --- a/client/gui-sdl2/dialogs.c +++ b/client/gui-sdl2/dialogs.c @@ -3236,7 +3236,7 @@ void popup_races_dialog(struct player *pplayer) natset_str = create_utf8_from_char_fonto(_("Nation set"), FONTO_ATTENTION); - change_ptsize_utf8(natset_str, adj_font(24)); + change_fonto_utf8(natset_str, FONTO_MAX); nationsets = create_iconlabel(NULL, pwindow->dst, natset_str, 0); add_to_gui_list(ID_LABEL, nationsets); @@ -3247,7 +3247,7 @@ void popup_races_dialog(struct player *pplayer) natset_str = create_utf8_from_char_fonto(nation_set_name_translation(setup->set), FONTO_ATTENTION); - change_ptsize_utf8(natset_str, adj_font(24)); + change_fonto_utf8(natset_str, FONTO_MAX); pwidget = create_iconlabel(NULL, pwindow->dst, natset_str, 0); @@ -3283,7 +3283,7 @@ void popup_races_dialog(struct player *pplayer) setup->nation_style = style_number(style_of_nation(pnat)); copy_chars_to_utf8_str(pstr, nation_plural_translation(pnat)); - change_ptsize_utf8(pstr, adj_font(24)); + change_fonto_utf8(pstr, FONTO_MAX); pstr->render = 2; pstr->fgcol = *get_theme_color(COLOR_THEME_NATIONDLG_TEXT); diff --git a/client/gui-sdl2/gui_string.c b/client/gui-sdl2/gui_string.c index 83c3be80ec..bcc72f6155 100644 --- a/client/gui-sdl2/gui_string.c +++ b/client/gui-sdl2/gui_string.c @@ -178,6 +178,9 @@ static Uint16 fonto_ptsize(enum font_origin origin) case FONTO_BIG: def = ptsize_default(); return adj_font(MAX(def + 3, def * 1.6)); + case FONTO_MAX: + def = ptsize_default(); + return adj_font(MAX(def + 7, def * 2.4)); } return 0; diff --git a/client/gui-sdl2/gui_string.h b/client/gui-sdl2/gui_string.h index 1ce4a0ecb6..d1844d1592 100644 --- a/client/gui-sdl2/gui_string.h +++ b/client/gui-sdl2/gui_string.h @@ -65,7 +65,8 @@ enum font_origin { FONTO_SLIGHTLY_BIGGER, FONTO_ATTENTION, FONTO_HEADING, - FONTO_BIG + FONTO_BIG, + FONTO_MAX }; utf8_str *create_utf8_str_fonto(char *in_text, size_t n_alloc, diff --git a/client/gui-sdl2/helpdlg.c b/client/gui-sdl2/helpdlg.c index e2bc600168..9e68624bb9 100644 --- a/client/gui-sdl2/helpdlg.c +++ b/client/gui-sdl2/helpdlg.c @@ -372,10 +372,12 @@ void popup_impr_info(Impr_type_id impr) pimpr_type = improvement_by_number(impr); surf = get_building_surface(pimpr_type); - impr_name_label = create_iconlabel_from_chars( - resize_surface_box(surf, adj_size(64), adj_size(48), 1, TRUE, TRUE), - pwindow->dst, city_improvement_name_translation(NULL, pimpr_type), - adj_font(24), WF_FREE_THEME); + impr_name_label + = create_iconlabel_from_chars_fonto(resize_surface_box(surf, adj_size(64), + adj_size(48), 1, TRUE, TRUE), + pwindow->dst, + city_improvement_name_translation(NULL, pimpr_type), + FONTO_MAX, WF_FREE_THEME); impr_name_label->id = ID_LABEL; widget_add_as_prev(impr_name_label, dock); @@ -799,10 +801,11 @@ void popup_unit_info(Unit_type_id type_id) } punittype = utype_by_number(type_id); - unit_name_label = create_iconlabel_from_chars( - adj_surf(get_unittype_surface(punittype, direction8_invalid())), - pwindow->dst, utype_name_translation(punittype), - adj_font(24), WF_FREE_THEME); + unit_name_label + = create_iconlabel_from_chars_fonto(adj_surf(get_unittype_surface(punittype, + direction8_invalid())), + pwindow->dst, utype_name_translation(punittype), + FONTO_MAX, WF_FREE_THEME); unit_name_label->id = ID_LABEL; widget_add_as_prev(unit_name_label, dock); @@ -1152,11 +1155,11 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, dock = pwidget; /* Tech name (heading) */ - pwidget = create_iconlabel_from_chars(get_tech_icon(tech), - pwindow->dst, - advance_name_translation(advance_by_number(tech)), - adj_font(24), - WF_FREE_THEME); + pwidget + = create_iconlabel_from_chars_fonto(get_tech_icon(tech), + pwindow->dst, + advance_name_translation(advance_by_number(tech)), + FONTO_MAX, WF_FREE_THEME); pwidget->id = ID_LABEL; widget_add_as_prev(pwidget, dock); diff --git a/client/gui-sdl2/mapctrl.c b/client/gui-sdl2/mapctrl.c index 5f8565f38f..d8c4025e74 100644 --- a/client/gui-sdl2/mapctrl.c +++ b/client/gui-sdl2/mapctrl.c @@ -750,7 +750,7 @@ static void popup_minimap_scale_dialog(void) add_to_gui_list(ID_BUTTON, buf); fc_snprintf(cbuf, sizeof(cbuf), "%d" , OVERVIEW_TILE_WIDTH); - pstr = create_utf8_from_char(cbuf, adj_font(24)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_MAX); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND); buf->size.w = MAX(adj_size(50), buf->size.w); @@ -771,7 +771,7 @@ static void popup_minimap_scale_dialog(void) add_to_gui_list(ID_BUTTON, buf); fc_snprintf(cbuf, sizeof(cbuf), "%d" , OVERVIEW_TILE_HEIGHT); - pstr = create_utf8_from_char(cbuf, adj_font(24)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_MAX); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND); buf->size.w = MAX(adj_size(50), buf->size.w); -- 2.40.1