From 8decb04054abf5c94a917637a276d59190acf33f Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 17 Sep 2023 05:46:53 +0300 Subject: [PATCH 12/12] 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 | 28 +++++++++++++++------------- client/gui-sdl2/mapctrl.c | 4 ++-- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/client/gui-sdl2/dialogs.c b/client/gui-sdl2/dialogs.c index 3028a478d5..f519c9cd70 100644 --- a/client/gui-sdl2/dialogs.c +++ b/client/gui-sdl2/dialogs.c @@ -3185,7 +3185,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); @@ -3196,7 +3196,7 @@ void popup_races_dialog(struct player *pplayer) natset_str = create_utf8_from_char_fonto(nation_set_name_translation(pSetup->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); @@ -3232,7 +3232,7 @@ void popup_races_dialog(struct player *pplayer) pSetup->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 19aa49a0ba..5089594250 100644 --- a/client/gui-sdl2/gui_string.c +++ b/client/gui-sdl2/gui_string.c @@ -177,6 +177,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 611ac9e042..a4d4aa2597 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 41db373e05..1b415c5489 100644 --- a/client/gui-sdl2/helpdlg.c +++ b/client/gui-sdl2/helpdlg.c @@ -371,10 +371,12 @@ void popup_impr_info(Impr_type_id impr) pImpr_type = improvement_by_number(impr); pSurf = get_building_surface(pImpr_type); - pImprNameLabel = create_iconlabel_from_chars( - ResizeSurfaceBox(pSurf, adj_size(64), adj_size(48), 1, TRUE, TRUE), - pWindow->dst, city_improvement_name_translation(NULL, pImpr_type), - adj_font(24), WF_FREE_THEME); + pImprNameLabel + = create_iconlabel_from_chars_fonto(ResizeSurfaceBox(pSurf, adj_size(64), adj_size(48), + 1, TRUE, TRUE), + pWindow->dst, + city_improvement_name_translation(NULL, pImpr_type), + FONTO_MAX, WF_FREE_THEME); pImprNameLabel->ID = ID_LABEL; DownAdd(pImprNameLabel, pDock); @@ -794,10 +796,11 @@ void popup_unit_info(Unit_type_id type_id) } pUnitType = utype_by_number(type_id); - pUnitNameLabel= create_iconlabel_from_chars( - adj_surf(get_unittype_surface(pUnitType, direction8_invalid())), - pWindow->dst, utype_name_translation(pUnitType), - adj_font(24), WF_FREE_THEME); + pUnitNameLabel + = create_iconlabel_from_chars_fonto(adj_surf(get_unittype_surface(pUnitType, + direction8_invalid())), + pWindow->dst, utype_name_translation(pUnitType), + FONTO_MAX, WF_FREE_THEME); pUnitNameLabel->ID = ID_LABEL; DownAdd(pUnitNameLabel, pDock); @@ -1142,11 +1145,10 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, pDock = 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; DownAdd(pWidget, pDock); diff --git a/client/gui-sdl2/mapctrl.c b/client/gui-sdl2/mapctrl.c index 4917c707a4..9ed2f7283a 100644 --- a/client/gui-sdl2/mapctrl.c +++ b/client/gui-sdl2/mapctrl.c @@ -740,7 +740,7 @@ static void popup_minimap_scale_dialog(void) add_to_gui_list(ID_BUTTON, pBuf); 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); pBuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); pBuf->size.w = MAX(adj_size(50), pBuf->size.w); @@ -759,7 +759,7 @@ static void popup_minimap_scale_dialog(void) add_to_gui_list(ID_BUTTON, pBuf); 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); pBuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); pBuf->size.w = MAX(adj_size(50), pBuf->size.w); -- 2.40.1