From a511f073e100ed6441cfde9d4ee3e7ad2d60a82f Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 17 Sep 2023 05:50:30 +0300 Subject: [PATCH 4/4] 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 | 34 ++++++++++++++++++---------------- client/gui-sdl2/mapctrl.c | 4 ++-- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/client/gui-sdl2/dialogs.c b/client/gui-sdl2/dialogs.c index 705705bd0a..0793e7e29c 100644 --- a/client/gui-sdl2/dialogs.c +++ b/client/gui-sdl2/dialogs.c @@ -3170,7 +3170,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); @@ -3181,7 +3181,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); @@ -3217,7 +3217,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 54fa14ddf9..e775e50122 100644 --- a/client/gui-sdl2/gui_string.c +++ b/client/gui-sdl2/gui_string.c @@ -180,6 +180,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 668f0d2f89..9ba812dbb6 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); @@ -797,10 +799,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); @@ -1136,7 +1139,7 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, start_x = (pWindow->area.x + adj_size(1) + width + pHelpDlg->pActiveWidgetList->size.w + adj_size(20)); - /* tech tree icon */ + /* Tech tree icon */ pWidget = create_icon2(current_theme->Tech_Tree_Icon, pWindow->dst, WF_RESTORE_BACKGROUND); @@ -1146,18 +1149,17 @@ static struct widget *create_tech_info(Tech_type_id tech, int width, DownAdd(pWidget, pDock); 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); + /* Tech name (heading) */ + 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); pDock = pWidget; - /* target techs */ + /* Target techs */ targets_count = 0; advance_index_iterate(A_FIRST, aidx) { if ((targets_count < 6) diff --git a/client/gui-sdl2/mapctrl.c b/client/gui-sdl2/mapctrl.c index 77156c75ca..429499051d 100644 --- a/client/gui-sdl2/mapctrl.c +++ b/client/gui-sdl2/mapctrl.c @@ -741,7 +741,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); @@ -760,7 +760,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