From 3c724c4e83d0098c0c093cc551dfbaef210a70d8 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 3 Apr 2023 19:50:29 +0300 Subject: [PATCH 16/16] sdl2: Use theme provided default font size It was previously completely unused. - Turn every place that formerly used font size 10 to use theme provided size instead - Change font size in the human theme to 10 Net effect is that nothing changes for users who are just using the provided theme, but it's now possible to change font size on that theme so that it does have an effect. The chaneg is done by introducing a new font_origin concept to use. Initially there's just one possible value FONTO_DEFAULT, but this can be extended in the future to support adjusting also also those font sizes not touched by this patch (anything that was not size 10) Lack of font size control reported by tigertoes See osdn #47703 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/action_dialog.c | 2 +- client/gui-sdl2/chatline.c | 2 - client/gui-sdl2/citydlg.c | 50 ++++++++------- client/gui-sdl2/cityrep.c | 34 +++++----- client/gui-sdl2/cma_fe.c | 61 ++++++++++-------- client/gui-sdl2/connectdlg.c | 24 +++---- client/gui-sdl2/dialogs.c | 10 +-- client/gui-sdl2/diplodlg.c | 2 +- client/gui-sdl2/finddlg.c | 2 +- client/gui-sdl2/gui_main.c | 9 +++ client/gui-sdl2/gui_main.h | 4 +- client/gui-sdl2/gui_string.c | 34 ++++++++++ client/gui-sdl2/gui_string.h | 13 +++- client/gui-sdl2/gui_tilespec.c | 4 +- client/gui-sdl2/helpdlg.c | 29 +++++---- client/gui-sdl2/inteldlg.c | 2 +- client/gui-sdl2/mapctrl.c | 22 ++++--- client/gui-sdl2/mapview.c | 4 +- client/gui-sdl2/menu.c | 74 +++++++++++----------- client/gui-sdl2/messagewin.c | 3 +- client/gui-sdl2/plrdlg.c | 8 +-- client/gui-sdl2/repodlgs.c | 64 +++++++++---------- client/gui-sdl2/themes.c | 5 +- client/gui-sdl2/themespec.c | 2 +- client/gui-sdl2/widget_button.h | 7 ++ client/gui-sdl2/widget_combo.c | 4 +- client/gui-sdl2/widget_edit.h | 7 +- client/gui-sdl2/widget_label.h | 5 +- client/gui-sdl2/wldlg.c | 70 ++++++++++---------- data/themes/gui-sdl2/human/theme.themespec | 2 +- 30 files changed, 329 insertions(+), 230 deletions(-) diff --git a/client/gui-sdl2/action_dialog.c b/client/gui-sdl2/action_dialog.c index 836f150902..bfa3d96b0b 100644 --- a/client/gui-sdl2/action_dialog.c +++ b/client/gui-sdl2/action_dialog.c @@ -835,7 +835,7 @@ static int spy_steal_popup_shared(struct widget *pWidget) } } - pstr = create_utf8_str(NULL, 0, adj_font(10)); + pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD | SF_CENTER); count = 0; diff --git a/client/gui-sdl2/chatline.c b/client/gui-sdl2/chatline.c index 4dfe34beba..6077d59880 100644 --- a/client/gui-sdl2/chatline.c +++ b/client/gui-sdl2/chatline.c @@ -59,8 +59,6 @@ #include "chatline.h" -#define PTSIZE_LOG_FONT adj_font(10) - struct CONNLIST { struct ADVANCED_DLG *pUsers_Dlg; struct ADVANCED_DLG *pChat_Dlg; diff --git a/client/gui-sdl2/citydlg.c b/client/gui-sdl2/citydlg.c index fc3ac91fc8..9319c46c26 100644 --- a/client/gui-sdl2/citydlg.c +++ b/client/gui-sdl2/citydlg.c @@ -748,7 +748,7 @@ static void create_present_supported_units_widget_list(struct unit_list *pList) pSurf = adj_surf(create_unit_surface(pUnit, FALSE, w, h)); } - pstr = create_utf8_from_char(cBuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pBuf = create_icon2(pSurf, pWindow->dst, WF_FREE_THEME @@ -960,7 +960,7 @@ static void create_city_options_widget_list(struct city *pCity) fc_snprintf(cBuf, sizeof(cBuf), _("Allow unit production\nto disband city")); - pstr = create_utf8_from_char(cBuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pstr->style |= TTF_STYLE_BOLD; pstr->fgcol = *get_theme_color(COLOR_THEME_CHECKBOX_LABEL_TEXT); @@ -1203,8 +1203,8 @@ void popup_hurry_production_dialog(struct city *pCity, SDL_Surface *pDest) /* ============================================================= */ - /* label */ - pstr = create_utf8_from_char(cBuf, adj_font(10)); + /* Label */ + pstr = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_BUY); @@ -1418,25 +1418,28 @@ static int sell_imprvm_dlg_callback(struct widget *pImpr) "Sell %s for %d gold?", price), city_improvement_name_translation(pCityDlg->pCity, improvement_by_number(id)), price); - pstr = create_utf8_from_char(cBuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_SELL); pLabel = create_iconlabel(NULL, pWindow->dst, pstr, 0); add_to_gui_list(ID_LABEL, pLabel); - /* create cancel button */ + /* Create cancel button */ pCancel_Button = - create_themeicon_button_from_chars(current_theme->Small_CANCEL_Icon, - pWindow->dst, _("Cancel"), adj_font(10), 0); + create_themeicon_button_from_chars_fonto( + current_theme->Small_CANCEL_Icon, + pWindow->dst, _("Cancel"), + FONTO_DEFAULT, 0); pCancel_Button->action = sell_imprvm_dlg_cancel_callback; pCancel_Button->key = SDLK_ESCAPE; set_wstate(pCancel_Button, FC_WS_NORMAL); add_to_gui_list(ID_BUTTON, pCancel_Button); - /* create ok button */ - pOK_Button = create_themeicon_button_from_chars(current_theme->Small_OK_Icon, + /* Create ok button */ + pOK_Button = create_themeicon_button_from_chars_fonto( + current_theme->Small_OK_Icon, pWindow->dst, _("Sell"), - adj_font(10), 0); + FONTO_DEFAULT, 0); pOK_Button->data.ptr = (void *)pImpr; pOK_Button->size.w = pCancel_Button->size.w; pOK_Button->action = sell_imprvm_dlg_ok_callback; @@ -1753,7 +1756,7 @@ static void redraw_misc_city_dialog(struct widget *pCityWindow, fc_snprintf(cBuf, sizeof(cBuf), _("City options")); - pstr = create_utf8_from_char(cBuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_PANEL); pstr->style |= TTF_STYLE_BOLD; @@ -1798,7 +1801,7 @@ static void redraw_supported_units_city_dialog(struct widget *pCityWindow, fc_snprintf(cBuf, sizeof(cBuf), _("Supported units: %d"), size); - pstr = create_utf8_from_char(cBuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_PANEL); pstr->style |= TTF_STYLE_BOLD; @@ -1855,7 +1858,7 @@ static void redraw_army_city_dialog(struct widget *pCityWindow, fc_snprintf(cBuf, sizeof(cBuf), _("Present units: %d"), size); - pstr = create_utf8_from_char(cBuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_PANEL); pstr->style |= TTF_STYLE_BOLD; @@ -1903,7 +1906,7 @@ static void redraw_info_city_dialog(struct widget *pCityWindow, SDL_Rect dest; fc_snprintf(cBuf, sizeof(cBuf), _("City info")); - pstr = create_utf8_from_char(cBuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_PANEL); pstr->style |= TTF_STYLE_BOLD; @@ -2071,7 +2074,7 @@ static void redraw_happiness_city_dialog(const struct widget *pCityWindow, fc_snprintf(cBuf, sizeof(cBuf), _("Happiness")); - pstr = create_utf8_from_char(cBuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_PANEL); pstr->style |= TTF_STYLE_BOLD; @@ -2422,14 +2425,14 @@ static void redraw_city_dialog(struct city *pCity) FREESURFACE(pCityDlg->pResource_Map->theme); pCityDlg->pResource_Map->theme = get_scaled_city_map(pCity); - /* redraw city dlg */ + /* Redraw city dlg */ redraw_group(pCityDlg->pBeginCityWidgetList, pCityDlg->pEndCityWidgetList, 0); /* ================================================================= */ fc_snprintf(cBuf, sizeof(cBuf), _("City map")); - pstr = create_utf8_from_char(cBuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_GOLD); pstr->style |= TTF_STYLE_BOLD; @@ -3397,9 +3400,11 @@ static void rebuild_imprm_list(struct city *pCity) pAdd_Dock = pCityDlg->pAdd_Point; pBuf = pLast = pAdd_Dock; - /* allock new */ + /* Alloc new */ city_built_iterate(pCity, pImprove) { - pstr = create_utf8_from_char(city_improvement_name_translation(pCity, pImprove), adj_font(10)); + pstr = create_utf8_from_char_fonto( + city_improvement_name_translation(pCity, pImprove), + FONTO_DEFAULT); pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_IMPR); pstr->style |= TTF_STYLE_BOLD; @@ -3713,8 +3718,9 @@ void real_city_dialog_popup(struct city *pCity) add_to_gui_list(ID_CITY_DLG_NEXT_BUTTON, pBuf); /* -------- */ - pBuf = create_edit_from_chars(NULL, pWindow->dst, city_name_get(pCity), - adj_font(10), adj_size(200), WF_RESTORE_BACKGROUND); + pBuf = create_edit_from_chars_fonto(NULL, pWindow->dst, city_name_get(pCity), + FONTO_DEFAULT, adj_size(200), + WF_RESTORE_BACKGROUND); pBuf->action = new_name_city_dlg_callback; pBuf->size.x = area.x + (area.w - pBuf->size.w) / 2; pBuf->size.y = area.y + area.h - pBuf->size.h - adj_size(2); diff --git a/client/gui-sdl2/cityrep.c b/client/gui-sdl2/cityrep.c index 83923ee3e5..e115f41d13 100644 --- a/client/gui-sdl2/cityrep.c +++ b/client/gui-sdl2/cityrep.c @@ -198,7 +198,7 @@ static void real_info_city_report_dialog_update(void) } fc_snprintf(cbuf, sizeof(cbuf), _("size")); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pText1 = create_text_surf_from_utf8(pstr); @@ -322,7 +322,7 @@ static void real_info_city_report_dialog_update(void) /* ----------- */ fc_snprintf(cbuf, sizeof(cbuf), "%d", city_size_get(pCity)); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pbuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -347,7 +347,7 @@ static void real_info_city_report_dialog_update(void) /* ----------- */ fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->prod[O_FOOD] - pCity->surplus[O_FOOD]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pstr->fgcol = *get_game_color(COLOR_OVERVIEW_LAND); pbuf = create_iconlabel(NULL, pWindow->dst, pstr, @@ -361,7 +361,7 @@ static void real_info_city_report_dialog_update(void) /* ----------- */ fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->surplus[O_FOOD]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_FOOD_SURPLUS); pbuf = create_iconlabel(NULL, pWindow->dst, pstr, @@ -387,7 +387,7 @@ static void real_info_city_report_dialog_update(void) break; } - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; if (togrow < 0) { pstr->fgcol.r = 255; @@ -403,7 +403,7 @@ static void real_info_city_report_dialog_update(void) /* ----------- */ fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->surplus[O_TRADE]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_TRADE); pbuf = create_iconlabel(NULL, pWindow->dst, pstr, @@ -417,7 +417,7 @@ static void real_info_city_report_dialog_update(void) /* ----------- */ fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->waste[O_TRADE]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pbuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -430,7 +430,7 @@ static void real_info_city_report_dialog_update(void) /* ----------- */ fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->surplus[O_GOLD]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_GOLD); pbuf = create_iconlabel(NULL, pWindow->dst, pstr, @@ -444,7 +444,7 @@ static void real_info_city_report_dialog_update(void) /* ----------- */ fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->prod[O_SCIENCE]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_SCIENCE); pbuf = create_iconlabel(NULL, pWindow->dst, pstr, @@ -458,7 +458,7 @@ static void real_info_city_report_dialog_update(void) /* ----------- */ fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->prod[O_LUXURY]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_LUX); pbuf = create_iconlabel(NULL, pWindow->dst, pstr, @@ -473,7 +473,7 @@ static void real_info_city_report_dialog_update(void) /* ----------- */ fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->prod[O_SHIELD] + pCity->waste[O_SHIELD]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_PROD); pbuf = create_iconlabel(NULL, pWindow->dst, pstr, @@ -487,7 +487,7 @@ static void real_info_city_report_dialog_update(void) /* ----------- */ fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->waste[O_SHIELD]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pbuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -501,7 +501,7 @@ static void real_info_city_report_dialog_update(void) /* ----------- */ fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->prod[O_SHIELD] + pCity->waste[O_SHIELD] - pCity->surplus[O_SHIELD]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_SUPPORT); pbuf = create_iconlabel(NULL, pWindow->dst, pstr, @@ -515,7 +515,7 @@ static void real_info_city_report_dialog_update(void) /* ----------- */ fc_snprintf(cbuf, sizeof(cbuf), "%d", pCity->surplus[O_SHIELD]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pstr->fgcol = *get_theme_color(COLOR_THEME_CITYDLG_TRADE); pbuf = create_iconlabel(NULL, pWindow->dst, pstr, @@ -558,8 +558,8 @@ static void real_info_city_report_dialog_update(void) pCity->shield_stock > togrow ? _("\nfinished"): "" ); } - /* info string */ - pstr = create_utf8_from_char(cbuf, adj_font(10)); + /* Info string */ + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; togrow = city_production_turns_to_build(pCity, TRUE); @@ -583,7 +583,7 @@ static void real_info_city_report_dialog_update(void) pbuf->action = popup_worklist_from_city_report_callback; pbuf->data.city = pCity; - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pstr->fgcol = *get_theme_color(COLOR_THEME_CITYREP_TEXT); pbuf = create_iconlabel(NULL, pWindow->dst, pstr, diff --git a/client/gui-sdl2/cma_fe.c b/client/gui-sdl2/cma_fe.c index 9bd1164cc2..b5d9da9d39 100644 --- a/client/gui-sdl2/cma_fe.c +++ b/client/gui-sdl2/cma_fe.c @@ -328,8 +328,9 @@ static int save_cma_callback(struct widget *pWidget) area.h = MAX(area.h, 1); /* ============================================================= */ - /* label */ - pstr = create_utf8_from_char(_("What should we name the preset?"), adj_font(10)); + /* Label */ + pstr = create_utf8_from_char_fonto(_("What should we name the preset?"), + FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); pstr->fgcol = *get_theme_color(COLOR_THEME_CMA_TEXT); @@ -521,7 +522,7 @@ static void popup_load_del_presets_dialog(bool load, struct widget *pButton) /* ---------- */ for (i = 0; i < count; i++) { - pstr = create_utf8_from_char(cmafec_preset_get_descr(i), adj_font(10)); + pstr = create_utf8_from_char_fonto(cmafec_preset_get_descr(i), FONTO_DEFAULT); pstr->style |= TTF_STYLE_BOLD; pBuf = create_iconlabel(NULL, pWindow->dst, pstr, (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE)); @@ -950,14 +951,15 @@ void popup_city_cma_dialog(struct city *pCity) pText[i] = create_text_surf_from_utf8(pstr); text_w = MAX(text_w, pText[i]->w); - /* minimal label */ + /* Minimal label */ pBuf = create_iconlabel(NULL, pWindow->dst, - create_utf8_from_char("999", adj_font(10)), + create_utf8_from_char_fonto("999", + FONTO_DEFAULT), (WF_FREE_STRING | WF_RESTORE_BACKGROUND)); add_to_gui_list(ID_LABEL, pBuf); - /* minimal scrollbar */ + /* Minimal scrollbar */ pBuf = create_horizontal(current_theme->Horiz, pWindow->dst, adj_size(30), (WF_RESTORE_BACKGROUND)); @@ -968,14 +970,15 @@ void popup_city_cma_dialog(struct city *pCity) add_to_gui_list(ID_SCROLLBAR, pBuf); - /* factor label */ + /* Factor label */ pBuf = create_iconlabel(NULL, pWindow->dst, - create_utf8_from_char("999", adj_font(10)), + create_utf8_from_char_fonto("999", + FONTO_DEFAULT), (WF_FREE_STRING | WF_RESTORE_BACKGROUND)); add_to_gui_list(ID_LABEL, pBuf); - /* factor scrollbar */ + /* Factor scrollbar */ pBuf = create_horizontal(current_theme->Horiz, pWindow->dst, adj_size(30), (WF_RESTORE_BACKGROUND)); @@ -991,14 +994,15 @@ void popup_city_cma_dialog(struct city *pCity) pText[O_LAST] = create_text_surf_from_utf8(pstr); FREEUTF8STR(pstr); - /* happy factor label */ + /* Happy factor label */ pBuf = create_iconlabel(NULL, pWindow->dst, - create_utf8_from_char("999", adj_font(10)), + create_utf8_from_char_fonto("999", + FONTO_DEFAULT), (WF_FREE_STRING | WF_RESTORE_BACKGROUND)); add_to_gui_list(ID_LABEL, pBuf); - /* happy factor scrollbar */ + /* Happy factor scrollbar */ pBuf = create_horizontal(current_theme->Horiz, pWindow->dst, adj_size(30), (WF_RESTORE_BACKGROUND)); @@ -1017,54 +1021,57 @@ void popup_city_cma_dialog(struct city *pCity) pBuf->action = toggle_cma_celebrating_callback; add_to_gui_list(ID_CHECKBOX, pBuf); - /* save as ... */ + /* Save as ... */ pBuf = create_themeicon(current_theme->SAVE_Icon, pWindow->dst, WF_RESTORE_BACKGROUND |WF_WIDGET_HAS_INFO_LABEL); pBuf->action = save_cma_callback; - pBuf->info_label = create_utf8_from_char(_("Save settings as..."), - adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(_("Save settings as..."), + FONTO_DEFAULT); add_to_gui_list(ID_ICON, pBuf); - /* load settings */ + /* Load settings */ pBuf = create_themeicon(current_theme->LOAD_Icon, pWindow->dst, WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL); pBuf->action = load_cma_callback; - pBuf->info_label = create_utf8_from_char(_("Load settings"), - adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(_("Load settings"), + FONTO_DEFAULT); add_to_gui_list(ID_ICON, pBuf); - /* del settings */ + /* Del settings */ pBuf = create_themeicon(current_theme->DELETE_Icon, pWindow->dst, WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL); pBuf->action = del_cma_callback; - pBuf->info_label = create_utf8_from_char(_("Delete settings"), - adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(_("Delete settings"), + FONTO_DEFAULT); add_to_gui_list(ID_ICON, pBuf); - /* run cma */ + /* Run cma */ pBuf = create_themeicon(current_theme->QPROD_Icon, pWindow->dst, WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL); pBuf->action = run_cma_callback; - pBuf->info_label = create_utf8_from_char(_("Control city"), adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(_("Control city"), + FONTO_DEFAULT); add_to_gui_list(ID_ICON, pBuf); - /* run cma onece */ + /* Run cma onece */ pBuf = create_themeicon(current_theme->FindCity_Icon, pWindow->dst, WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL); pBuf->action = run_cma_once_callback; - pBuf->info_label = create_utf8_from_char(_("Apply once"), adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(_("Apply once"), + FONTO_DEFAULT); add_to_gui_list(ID_ICON, pBuf); - /* del settings */ + /* Del settings */ pBuf = create_themeicon(current_theme->Support_Icon, pWindow->dst, WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL); pBuf->action = stop_cma_callback; - pBuf->info_label = create_utf8_from_char(_("Release city"), adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(_("Release city"), + FONTO_DEFAULT); add_to_gui_list(ID_ICON, pBuf); diff --git a/client/gui-sdl2/connectdlg.c b/client/gui-sdl2/connectdlg.c index 4ddfd27ab6..3ec0ee4272 100644 --- a/client/gui-sdl2/connectdlg.c +++ b/client/gui-sdl2/connectdlg.c @@ -333,8 +333,8 @@ void popup_connection_dialog(bool lan_scan) pServer->host, pServer->port, pServer->version, _(pServer->state), Q_("?header:Players"), pServer->nplayers, pServer->message); - pNewWidget = create_iconlabel_from_chars(NULL, pWindow->dst, cBuf, - adj_font(10), + pNewWidget = create_iconlabel_from_chars_fonto(NULL, pWindow->dst, cBuf, + FONTO_DEFAULT, WF_FREE_STRING|WF_DRAW_TEXT_LABEL_WITH_SPACE|WF_RESTORE_BACKGROUND); pNewWidget->string_utf8->style |= SF_CENTER; @@ -560,22 +560,22 @@ void popup_join_game_dialog(void) pConnectDlg = fc_calloc(1, sizeof(struct SMALL_DLG)); - /* window */ + /* Window */ pWindow = create_window_skeleton(NULL, NULL, 0); add_to_gui_list(ID_WINDOW, pWindow); pConnectDlg->pEndWidgetList = pWindow; area = pWindow->area; - /* player name label */ - plrname = create_utf8_from_char(_("Player Name :"), adj_font(10)); + /* Player name label */ + plrname = create_utf8_from_char_fonto(_("Player Name :"), FONTO_DEFAULT); plrname->fgcol = *get_theme_color(COLOR_THEME_JOINGAMEDLG_TEXT); pBuf = create_iconlabel(NULL, pWindow->dst, plrname, (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE)); add_to_gui_list(ID_LABEL, pBuf); area.h += pBuf->size.h + adj_size(20); - /* player name edit */ + /* Player name edit */ pBuf = create_edit_from_chars(NULL, pWindow->dst, user_name, adj_font(14), adj_size(210), (WF_RESTORE_BACKGROUND|WF_FREE_DATA)); pBuf->action = convert_playername_callback; @@ -583,15 +583,15 @@ void popup_join_game_dialog(void) add_to_gui_list(ID_PLAYER_NAME_EDIT, pBuf); area.h += pBuf->size.h + adj_size(5); - /* server name label */ - srvname = create_utf8_from_char(_("Freeciv Server :"), adj_font(10)); + /* Server name label */ + srvname = create_utf8_from_char_fonto(_("Freeciv Server :"), FONTO_DEFAULT); srvname->fgcol = *get_theme_color(COLOR_THEME_JOINGAMEDLG_TEXT); pBuf = create_iconlabel(NULL, pWindow->dst, srvname, (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE)); add_to_gui_list(ID_LABEL, pBuf); area.h += pBuf->size.h + adj_size(5); - /* server name edit */ + /* Server name edit */ pBuf = create_edit_from_chars(NULL, pWindow->dst, server_host, adj_font(14), adj_size(210), WF_RESTORE_BACKGROUND); @@ -600,15 +600,15 @@ void popup_join_game_dialog(void) add_to_gui_list(ID_SERVER_NAME_EDIT, pBuf); area.h += pBuf->size.h + adj_size(5); - /* port label */ - port_nr = create_utf8_from_char(_("Port :"), adj_font(10)); + /* Port label */ + port_nr = create_utf8_from_char_fonto(_("Port :"), FONTO_DEFAULT); port_nr->fgcol = *get_theme_color(COLOR_THEME_JOINGAMEDLG_TEXT); pBuf = create_iconlabel(NULL, pWindow->dst, port_nr, (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE)); add_to_gui_list(ID_LABEL, pBuf); area.h += pBuf->size.h + adj_size(5); - /* port edit */ + /* Port edit */ fc_snprintf(pCharPort, sizeof(pCharPort), "%d", server_port); pBuf = create_edit_from_chars(NULL, pWindow->dst, pCharPort, adj_font(14), adj_size(210), diff --git a/client/gui-sdl2/dialogs.c b/client/gui-sdl2/dialogs.c index 07a767260b..3869982835 100644 --- a/client/gui-sdl2/dialogs.c +++ b/client/gui-sdl2/dialogs.c @@ -706,8 +706,8 @@ void popup_unit_upgrade_dlg(struct unit *pUnit, bool city) /* ============================================================= */ - /* create text label */ - pstr = create_utf8_from_char(cBuf, adj_font(10)); + /* Create text label */ + pstr = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); pstr->fgcol = *get_theme_color(COLOR_THEME_UNITUPGRADE_TEXT); @@ -902,8 +902,8 @@ void popup_unit_disband_dlg(struct unit *pUnit, bool city) /* ============================================================= */ - /* create text label */ - pstr = create_utf8_from_char(cBuf, adj_font(10)); + /* Create text label */ + pstr = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); pstr->fgcol = *get_theme_color(COLOR_THEME_UNITDISBAND_TEXT); @@ -1718,7 +1718,7 @@ void popup_advanced_terrain_dialog(struct tile *ptile, Uint16 pos_x, Uint16 pos_ add_to_gui_list(ID_TERRAIN_ADV_DLG_EXIT_BUTTON, pBuf); /* ---------- */ - pstr = create_utf8_from_char(_("Terrain Info") , adj_font(10)); + pstr = create_utf8_from_char_fonto(_("Terrain Info"), FONTO_DEFAULT); pstr->style |= TTF_STYLE_BOLD; pBuf = create_iconlabel(NULL, pWindow->dst, pstr, diff --git a/client/gui-sdl2/diplodlg.c b/client/gui-sdl2/diplodlg.c index 910bed5fcb..38b93513ea 100644 --- a/client/gui-sdl2/diplodlg.c +++ b/client/gui-sdl2/diplodlg.c @@ -635,7 +635,7 @@ static struct ADVANCED_DLG *popup_diplomatic_objects(struct player *pPlayer0, count++; pBuf = create_edit(NULL, pWindow->dst, - create_utf8_from_char("0", adj_font(10)), 0, + create_utf8_from_char_fonto("0", FONTO_DEFAULT), 0, (WF_RESTORE_BACKGROUND|WF_FREE_STRING)); pBuf->data.cont = pCont; pBuf->action = gold_callback; diff --git a/client/gui-sdl2/finddlg.c b/client/gui-sdl2/finddlg.c index 2d9614bf94..086fb835e6 100644 --- a/client/gui-sdl2/finddlg.c +++ b/client/gui-sdl2/finddlg.c @@ -182,7 +182,7 @@ void popup_find_dialog(void) fc_snprintf(cBuf , sizeof(cBuf), "%s (%d)", city_name_get(pCity), city_size_get(pCity)); - pstr = create_utf8_from_char(cBuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); if (!player_owns_city(owner, pCity)) { diff --git a/client/gui-sdl2/gui_main.c b/client/gui-sdl2/gui_main.c index f040b3f517..ba2285923e 100644 --- a/client/gui-sdl2/gui_main.c +++ b/client/gui-sdl2/gui_main.c @@ -1241,6 +1241,15 @@ void gui_update_font(const char *font_name, const char *font_value) #undef CHECK_FONT } +/************************************************************************** + Update font sizes based on theme. +**************************************************************************/ +void update_font_from_theme(int theme_font_size) +{ + *client_font_sizes[FONT_CITY_NAME] = theme_font_size; + *client_font_sizes[FONT_CITY_PROD] = theme_font_size; +} + /************************************************************************** Insert build information to help **************************************************************************/ diff --git a/client/gui-sdl2/gui_main.h b/client/gui-sdl2/gui_main.h index bc57e3bc25..cc56822335 100644 --- a/client/gui-sdl2/gui_main.h +++ b/client/gui-sdl2/gui_main.h @@ -123,7 +123,9 @@ Uint16 gui_event_loop(void *pData, void (*loop_action)(void *pData), Uint16 (*mouse_motion_handler)(SDL_MouseMotionEvent *pMotionEvent, void *pData)); -/* shrink sizes for 320x240 screen */ +void update_font_from_theme(int theme_font_size); + +/* Shrink sizes for 320x240 screen */ #ifdef SMALL_SCREEN #define adj_size(size) ((size) / 2) #else diff --git a/client/gui-sdl2/gui_string.c b/client/gui-sdl2/gui_string.c index 14a7ec36fe..372235f67c 100644 --- a/client/gui-sdl2/gui_string.c +++ b/client/gui-sdl2/gui_string.c @@ -152,6 +152,20 @@ void utf8_str_size(utf8_str *pstr, SDL_Rect *fill) } } +/************************************************************************** + Convert font_origin to ptsize value +**************************************************************************/ +static Uint16 fonto_ptsize(enum font_origin origin) +{ + switch (origin) { + case FONTO_DEFAULT: + /* Rely on create_utf8_str() default */ + return 0; + } + + return 0; +} + /************************************************************************** Create utf8_str struct with ptsize font. If ptsize is zero, use theme's default font size. @@ -188,6 +202,18 @@ utf8_str *create_utf8_str(char *in_text, size_t n_alloc, Uint16 ptsize) return str; } +/************************************************************************** + Create utf8_str struct with font size from given origin. + + Font will be loaded or aliased with existing font of that size. + in_text must be allocated in memory (fc_malloc() / fc_calloc()) +**************************************************************************/ +utf8_str *create_utf8_str_fonto(char *in_text, size_t n_alloc, + enum font_origin origin) +{ + return create_utf8_str(in_text, n_alloc, fonto_ptsize(origin)); +} + /************************************************************************** Convert char array to utf8_str. Pointer to target string is needed as parameter, but also returned for convenience. @@ -515,6 +541,14 @@ void change_ptsize_utf8(utf8_str *pstr, Uint16 new_ptsize) pstr->font = buf; } +/**********************************************************************//** + Change font size of text to that from given origin. +**************************************************************************/ +void change_fonto_utf8(utf8_str *pstr, enum font_origin origin) +{ + change_ptsize_utf8(pstr, fonto_ptsize(origin)); +} + /* =================================================== */ /************************************************************************** diff --git a/client/gui-sdl2/gui_string.h b/client/gui-sdl2/gui_string.h index 7889fdba4a..85b9ea7e35 100644 --- a/client/gui-sdl2/gui_string.h +++ b/client/gui-sdl2/gui_string.h @@ -60,6 +60,12 @@ typedef struct utf8_str { char *text; } utf8_str; +enum font_origin { + FONTO_DEFAULT +}; + +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, @@ -70,6 +76,7 @@ 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); void change_ptsize_utf8(utf8_str *pstr, Uint16 new_ptsize); +void change_fonto_utf8(utf8_str *pstr, enum font_origin origin); void unload_font(Uint16 ptsize); void free_font_system(void); @@ -99,6 +106,10 @@ void free_font_system(void); (string_in) == NULL ? \ create_utf8_str(NULL, 0, ptsize) : \ copy_chars_to_utf8_str(create_utf8_str(NULL, 0, ptsize), string_in) - + +#define create_utf8_from_char_fonto(string_in, fonto) \ + (string_in) == NULL ? \ + create_utf8_str_fonto(NULL, 0, fonto) : \ + copy_chars_to_utf8_str(create_utf8_str_fonto(NULL, 0, fonto), string_in) #endif /* FC__GUISTRING_H */ diff --git a/client/gui-sdl2/gui_tilespec.c b/client/gui-sdl2/gui_tilespec.c index ce2de7f1a6..6913eb8ee7 100644 --- a/client/gui-sdl2/gui_tilespec.c +++ b/client/gui-sdl2/gui_tilespec.c @@ -378,11 +378,11 @@ void setup_auxiliary_tech_icons(void) { SDL_Color bg_color = {255, 255, 255, 136}; SDL_Surface *pSurf; - utf8_str *pstr = create_utf8_from_char(Q_("?tech:None"), adj_font(10)); + utf8_str *pstr = create_utf8_from_char_fonto(Q_("?tech:None"), FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD | SF_CENTER); - /* create icons */ + /* Create icons */ pSurf = create_surf(adj_size(50), adj_size(50), SDL_SWSURFACE); SDL_FillRect(pSurf, NULL, map_rgba(pSurf->format, bg_color)); create_frame(pSurf, diff --git a/client/gui-sdl2/helpdlg.c b/client/gui-sdl2/helpdlg.c index 231fe7ae2c..ce34fed733 100644 --- a/client/gui-sdl2/helpdlg.c +++ b/client/gui-sdl2/helpdlg.c @@ -272,7 +272,7 @@ void popup_impr_info(Impr_type_id impr) /* ------------------ */ pDock = pCloseButton; - pstr = create_utf8_str(NULL, 0, adj_font(10)); + pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD | SF_CENTER); /* Background template for entries in scroll list */ @@ -330,10 +330,11 @@ void popup_impr_info(Impr_type_id impr) } /* Toggle techs list button */ - pListToggleButton = create_themeicon_button_from_chars(current_theme->UP_Icon, + pListToggleButton = create_themeicon_button_from_chars_fonto( + current_theme->UP_Icon, pWindow->dst, _("Improvements"), - adj_font(10), 0); + FONTO_DEFAULT, 0); #if 0 pListToggleButton->action = toggle_full_tree_mode_in_help_dlg_callback; if (pStore->show_tree) { @@ -689,7 +690,7 @@ void popup_unit_info(Unit_type_id type_id) /* --- Create scrollable unit list on the left side ---*/ - pstr = create_utf8_str(NULL, 0, adj_font(10)); + pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD | SF_CENTER); /* Background template for entries in scroll list */ @@ -747,8 +748,9 @@ void popup_unit_info(Unit_type_id type_id) } /* Toggle techs list button */ - pListToggleButton = create_themeicon_button_from_chars(current_theme->UP_Icon, - pWindow->dst, _("Units"), adj_font(10), 0); + pListToggleButton = create_themeicon_button_from_chars_fonto( + current_theme->UP_Icon, + pWindow->dst, _("Units"), FONTO_DEFAULT, 0); #if 0 pListToggleButton->action = toggle_full_tree_mode_in_help_dlg_callback; if (pStore->show_tree) { @@ -1653,7 +1655,7 @@ static struct widget *create_tech_tree(Tech_type_id tech, int width, SDL_Surface *pSurf; struct widget *pDock = pStore->pDock; - pstr = create_utf8_str(NULL, 0, adj_font(10)); + pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD | SF_CENTER); copy_chars_to_utf8_str(pstr, advance_name_translation(advance_by_number(tech))); @@ -1949,7 +1951,7 @@ void popup_tech_info(Tech_type_id tech) pDock = pCloseButton; /* --- Create scrollable advance list on the left side ---*/ - pstr = create_utf8_str(NULL, 0, adj_font(10)); + pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD | SF_CENTER); tech_count = 0; @@ -1983,11 +1985,12 @@ void popup_tech_info(Tech_type_id tech) scrollbar_width = create_vertical_scrollbar(pHelpDlg, 1, 10, TRUE, TRUE); } - /* toggle techs list button */ - pListToggleButton = create_themeicon_button_from_chars(current_theme->UP_Icon, - pWindow->dst, - _("Advances"), - adj_font(10), 0); + /* Toggle techs list button */ + pListToggleButton = create_themeicon_button_from_chars_fonto( + current_theme->UP_Icon, + pWindow->dst, + _("Advances"), + FONTO_DEFAULT, 0); pListToggleButton->action = toggle_full_tree_mode_in_help_dlg_callback; if (pStore->show_tree) { set_wstate(pListToggleButton, FC_WS_NORMAL); diff --git a/client/gui-sdl2/inteldlg.c b/client/gui-sdl2/inteldlg.c index 4fca6540b7..9d77ba78c7 100644 --- a/client/gui-sdl2/inteldlg.c +++ b/client/gui-sdl2/inteldlg.c @@ -318,7 +318,7 @@ void update_intel_dialog(struct player *p) pCapital = player_capital(p); research = research_get(p); - change_ptsize_utf8(pstr, adj_font(10)); + change_fonto_utf8(pstr, FONTO_DEFAULT); pstr->style &= ~TTF_STYLE_BOLD; /* FIXME: these should use common gui code, and avoid duplication! */ diff --git a/client/gui-sdl2/mapctrl.c b/client/gui-sdl2/mapctrl.c index d5f5f6d4b3..ca7ae47158 100644 --- a/client/gui-sdl2/mapctrl.c +++ b/client/gui-sdl2/mapctrl.c @@ -2762,30 +2762,34 @@ void popup_newcity_dialog(struct unit *pUnit, const char *pSuggestname) area = pWindow->area; - /* create ok button */ + /* Create ok button */ pOK_Button = - create_themeicon_button_from_chars(current_theme->Small_OK_Icon, pWindow->dst, - _("OK"), adj_font(10), 0); + create_themeicon_button_from_chars_fonto(current_theme->Small_OK_Icon, + pWindow->dst, + _("OK"), FONTO_DEFAULT, 0); pOK_Button->action = newcity_ok_callback; pOK_Button->key = SDLK_RETURN; pOK_Button->data.tile = unit_tile(pUnit); area.h += pOK_Button->size.h; - /* create cancel button */ + /* Create cancel button */ pCancel_Button = - create_themeicon_button_from_chars(current_theme->Small_CANCEL_Icon, - pWindow->dst, _("Cancel"), adj_font(10), 0); + create_themeicon_button_from_chars_fonto( + current_theme->Small_CANCEL_Icon, + pWindow->dst, _("Cancel"), + FONTO_DEFAULT, 0); pCancel_Button->action = newcity_cancel_callback; pCancel_Button->key = SDLK_ESCAPE; pCancel_Button->data.tile = unit_tile(pUnit); - /* correct sizes */ + /* Correct sizes */ pCancel_Button->size.w += adj_size(5); pOK_Button->size.w = pCancel_Button->size.w; - /* create text label */ - pstr = create_utf8_from_char(_("What should we call our new city?"), adj_font(10)); + /* Create text label */ + pstr = create_utf8_from_char(_("What should we call our new city?"), + FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); pstr->fgcol = *get_theme_color(COLOR_THEME_NEWCITYDLG_TEXT); pLabel = create_iconlabel(NULL, pWindow->dst, pstr, WF_DRAW_TEXT_LABEL_WITH_SPACE); diff --git a/client/gui-sdl2/mapview.c b/client/gui-sdl2/mapview.c index e19d888b51..c215e35125 100644 --- a/client/gui-sdl2/mapview.c +++ b/client/gui-sdl2/mapview.c @@ -560,7 +560,7 @@ void redraw_unit_info_label(struct unit_list *punitlist) right = FALSE; } - change_ptsize_utf8(pstr, adj_font(10)); + change_fonto_utf8(pstr, FONTO_DEFAULT); vetname = utype_veteran_name_translation(unit_type_get(pUnit), pUnit->veteran); if (vetname != NULL) { @@ -570,7 +570,7 @@ void redraw_unit_info_label(struct unit_list *punitlist) pstr->fgcol = *get_theme_color(COLOR_THEME_MAPVIEW_UNITINFO_TEXT); } - /* get and draw other info (MP, terrain, city, etc.) */ + /* Get and draw other info (MP, terrain, city, etc.) */ pstr->style |= SF_CENTER; copy_chars_to_utf8_str(pstr, diff --git a/client/gui-sdl2/menu.c b/client/gui-sdl2/menu.c index 540faa57c5..917727126d 100644 --- a/client/gui-sdl2/menu.c +++ b/client/gui-sdl2/menu.c @@ -407,7 +407,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_SPACE; add_to_gui_list(ID_UNIT_ORDER_DONE, pBuf); /* --------- */ @@ -421,7 +421,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_w; add_to_gui_list(ID_UNIT_ORDER_WAIT, pBuf); /* --------- */ @@ -434,7 +434,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_n; pBuf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_NUKE, pBuf); @@ -448,7 +448,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_d; add_to_gui_list(ID_UNIT_ORDER_DIPLOMAT_DLG, pBuf); /* --------- */ @@ -460,7 +460,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_d; pBuf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_DISBAND, pBuf); @@ -473,7 +473,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_u; pBuf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_UPGRADE, pBuf); @@ -486,7 +486,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_o; pBuf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_CONVERT, pBuf); @@ -499,7 +499,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_g; pBuf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_RETURN, pBuf); @@ -512,7 +512,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_t; add_to_gui_list(ID_UNIT_ORDER_GOTO_CITY, pBuf); /* --------- */ @@ -524,7 +524,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_t; add_to_gui_list(ID_UNIT_ORDER_AIRLIFT, pBuf); /* --------- */ @@ -536,7 +536,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_g; add_to_gui_list(ID_UNIT_ORDER_GOTO, pBuf); /* --------- */ @@ -548,7 +548,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_q; add_to_gui_list(ID_UNIT_ORDER_PATROL, pBuf); /* --------- */ @@ -560,7 +560,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_i; pBuf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_CONNECT_IRRIGATE, pBuf); @@ -579,7 +579,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_r; pBuf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_CONNECT_ROAD, pBuf); @@ -598,7 +598,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_l; pBuf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_CONNECT_RAILROAD, pBuf); @@ -612,7 +612,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_x; add_to_gui_list(ID_UNIT_ORDER_AUTO_EXPLORE, pBuf); /* --------- */ @@ -625,7 +625,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_a; add_to_gui_list(ID_UNIT_ORDER_AUTO_SETTLER, pBuf); /* --------- */ @@ -637,7 +637,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_s; pBuf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_WAKEUP_OTHERS, pBuf); @@ -650,7 +650,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->mod = KMOD_SHIFT; pBuf->key = SDLK_t; add_to_gui_list(ID_UNIT_ORDER_UNLOAD_TRANSPORTER, pBuf); @@ -663,7 +663,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_l; add_to_gui_list(ID_UNIT_ORDER_LOAD, pBuf); /* --------- */ @@ -675,7 +675,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_u; add_to_gui_list(ID_UNIT_ORDER_UNLOAD, pBuf); /* --------- */ @@ -688,7 +688,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_h; add_to_gui_list(ID_UNIT_ORDER_HOMECITY, pBuf); /* --------- */ @@ -700,7 +700,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_p; pBuf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_PILLAGE, pBuf); @@ -713,7 +713,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_s; add_to_gui_list(ID_UNIT_ORDER_SENTRY, pBuf); /* --------- */ @@ -726,7 +726,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_n; pOrder_Fallout_Button = pBuf; add_to_gui_list(ID_UNIT_ORDER_FALLOUT, pBuf); @@ -740,7 +740,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_p; add_to_gui_list(ID_UNIT_ORDER_PARADROP, pBuf); /* --------- */ @@ -753,7 +753,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_p; pOrder_Pollution_Button = pBuf; add_to_gui_list(ID_UNIT_ORDER_POLLUTION, pBuf); @@ -767,7 +767,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_e; pBuf->mod = KMOD_SHIFT; pOrder_Airbase_Button = pBuf; @@ -781,7 +781,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_f; add_to_gui_list(ID_UNIT_ORDER_FORTIFY, pBuf); /* --------- */ @@ -794,7 +794,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_f; pBuf->mod = KMOD_SHIFT; pOrder_Fortress_Button = pBuf; @@ -809,7 +809,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_o; pOrder_Transform_Button = pBuf; add_to_gui_list(ID_UNIT_ORDER_TRANSFORM, pBuf); @@ -823,7 +823,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_m; add_to_gui_list(ID_UNIT_ORDER_MINE, pBuf); @@ -839,7 +839,7 @@ void create_units_order_widgets(void) set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; pBuf->key = SDLK_i; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char(cBuf, FONTO_DEFAULT); add_to_gui_list(ID_UNIT_ORDER_IRRIGATE, pBuf); pOrder_Irrigation_Button = pBuf; @@ -853,7 +853,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_r; add_to_gui_list(ID_UNIT_ORDER_TRADE_ROUTE, pBuf); @@ -868,7 +868,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_r; add_to_gui_list(ID_UNIT_ORDER_ROAD, pBuf); @@ -883,7 +883,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_b; add_to_gui_list(ID_UNIT_ORDER_BUILD_WONDER, pBuf); /* --------- */ @@ -896,7 +896,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = unit_order_callback; - pBuf->info_label = create_utf8_from_char(cBuf, adj_font(10)); + pBuf->info_label = create_utf8_from_char(cBuf, FONTO_DEFAULT); pBuf->key = SDLK_b; add_to_gui_list(ID_UNIT_ORDER_BUILD_CITY, pBuf); diff --git a/client/gui-sdl2/messagewin.c b/client/gui-sdl2/messagewin.c index ac32a5c0a1..fe41360d44 100644 --- a/client/gui-sdl2/messagewin.c +++ b/client/gui-sdl2/messagewin.c @@ -58,7 +58,8 @@ #define N_MSG_VIEW 6 #endif -#define PTSIZE_LOG_FONT adj_font(10) +/* 0 -> use theme default */ +#define PTSIZE_LOG_FONT 0 static struct ADVANCED_DLG *pMsg_Dlg = NULL; diff --git a/client/gui-sdl2/plrdlg.c b/client/gui-sdl2/plrdlg.c index e5dfd382cd..a30d779220 100644 --- a/client/gui-sdl2/plrdlg.c +++ b/client/gui-sdl2/plrdlg.c @@ -434,7 +434,7 @@ void popup_players_dialog(bool raise) continue; } - pstr = create_utf8_str(NULL, 0, adj_font(10)); + pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); pLogo = get_nation_flag_surface(nation_of_player(pPlayer)); @@ -452,7 +452,7 @@ void popup_players_dialog(bool raise) pBuf->info_label = pstr; if (!pPlayer->is_alive) { - pstr = create_utf8_from_char(_("R.I.P.") , adj_font(10)); + pstr = create_utf8_from_char_fonto(_("R.I.P."), FONTO_DEFAULT); pstr->style |= TTF_STYLE_BOLD; pstr->fgcol = *get_theme_color(COLOR_THEME_PLRDLG_TEXT); pLogo = create_text_surf_from_utf8(pstr); @@ -498,7 +498,7 @@ void popup_players_dialog(bool raise) pBuf->size.y = pWindow->size.y + adj_size(2); n = area.y; - pstr = create_utf8_str(NULL, 0, adj_font(10)); + pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT); pstr->style |= TTF_STYLE_BOLD; pstr->bgcol = (SDL_Color) {0, 0, 0, 0}; @@ -739,7 +739,7 @@ void popup_players_nations_dialog(void) state); } - pstr = create_utf8_from_char(cBuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pstr->style |= TTF_STYLE_BOLD; pLogo = get_nation_flag_surface(nation_of_player(pPlayer)); diff --git a/client/gui-sdl2/repodlgs.c b/client/gui-sdl2/repodlgs.c index 7cc83aa752..6f28003d29 100644 --- a/client/gui-sdl2/repodlgs.c +++ b/client/gui-sdl2/repodlgs.c @@ -238,8 +238,8 @@ static int popup_upgrade_unit_callback(struct widget *pWidget) /* ============================================================= */ - /* create text label */ - pstr = create_utf8_from_char(cBuf, adj_font(10)); + /* Create text label */ + pstr = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); pstr->fgcol = *get_theme_color(COLOR_THEME_UNITUPGRADE_TEXT); @@ -372,7 +372,7 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, } fc_snprintf(cbuf, sizeof(cbuf), _("active")); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pText1 = create_text_surf_from_utf8(pstr); @@ -419,10 +419,10 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, add_to_gui_list(ID_BUTTON, pBuf); /* ------------------------- */ - /* totals */ + /* Totals */ fc_snprintf(cbuf, sizeof(cbuf), "%d", total->active_count); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); pBuf = create_iconlabel(NULL, pWindow->dst, pstr, @@ -434,7 +434,7 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, /* ---------------------------------------------- */ fc_snprintf(cbuf, sizeof(cbuf), "%d", total->upkeep[O_SHIELD]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); pBuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -444,7 +444,7 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, /* ---------------------------------------------- */ fc_snprintf(cbuf, sizeof(cbuf), "%d", total->upkeep[O_FOOD]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); pBuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -454,7 +454,7 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, /* ---------------------------------------------- */ fc_snprintf(cbuf, sizeof(cbuf), "%d", total->upkeep[O_GOLD]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); pBuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -464,7 +464,7 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, /* ---------------------------------------------- */ fc_snprintf(cbuf, sizeof(cbuf), "%d", total->building_count); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); pBuf = create_iconlabel(NULL, pWindow->dst, pstr, @@ -510,9 +510,9 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, name_w = MAX(pBuf->size.w, name_w); add_to_gui_list(MAX_ID - utype_number(i), pBuf); - /* active */ + /* Active */ fc_snprintf(cbuf, sizeof(cbuf), "%d", units[utype_index(i)].active_count); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pBuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -523,9 +523,9 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, pBuf->size.w = pText1->w + adj_size(6); add_to_gui_list(MAX_ID - utype_number(i), pBuf); - /* shield upkeep */ + /* Shield upkeep */ fc_snprintf(cbuf, sizeof(cbuf), "%d", units[utype_index(i)].upkeep[O_SHIELD]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pBuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -536,9 +536,9 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, pBuf->size.w = pText1->w; add_to_gui_list(MAX_ID - utype_number(i), pBuf); - /* food upkeep */ + /* Food upkeep */ fc_snprintf(cbuf, sizeof(cbuf), "%d", units[utype_index(i)].upkeep[O_FOOD]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pBuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -550,9 +550,9 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, pBuf->size.w = pText1->w; add_to_gui_list(MAX_ID - utype_number(i), pBuf); - /* gold upkeep */ + /* Gold upkeep */ fc_snprintf(cbuf, sizeof(cbuf), "%d", units[utype_index(i)].upkeep[O_GOLD]); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pBuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -564,13 +564,13 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, pBuf->size.w = pText1->w; add_to_gui_list(MAX_ID - utype_number(i), pBuf); - /* building */ + /* Building */ if (units[utype_index(i)].building_count > 0) { fc_snprintf(cbuf, sizeof(cbuf), "%d", units[utype_index(i)].building_count); } else { fc_snprintf(cbuf, sizeof(cbuf), "--"); } - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pBuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -581,7 +581,7 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, pBuf->size.w = pText2->w + adj_size(6); add_to_gui_list(MAX_ID - utype_number(i), pBuf); - /* soonest completion */ + /* Soonest completion */ if (units[utype_index(i)].building_count > 0) { fc_snprintf(cbuf, sizeof(cbuf), "%d %s", units[utype_index(i)].soonest_completions, PL_("turn", "turns", units[utype_index(i)].soonest_completions)); @@ -589,7 +589,7 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, fc_snprintf(cbuf, sizeof(cbuf), "--"); } - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pBuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -1629,8 +1629,8 @@ static int popup_sell_impr_callback(struct widget *pWidget) /* ============================================================= */ - /* create text label */ - pstr = create_utf8_from_char(cBuf, adj_font(10)); + /* Create text label */ + pstr = create_utf8_from_char_fonto(cBuf, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD|SF_CENTER); pstr->fgcol = *get_theme_color(COLOR_THEME_SELLIMPR_TEXT); @@ -1956,11 +1956,11 @@ void economy_report_dialog_popup(bool make_modal) FREEUTF8STR(pstr2); /* ------------------------- */ - /* lux rate */ + /* Lux rate */ - /* lux rate lock */ + /* Lux rate lock */ fc_snprintf(cbuf, sizeof(cbuf), _("Lock")); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= TTF_STYLE_BOLD; pBuf = create_checkbox(pWindow->dst, @@ -2002,11 +2002,11 @@ void economy_report_dialog_popup(bool make_modal) w2 += (adj_size(5) + pBuf->size.w + adj_size(10)); /* ------------------------- */ - /* science rate */ + /* Science rate */ - /* science rate lock */ + /* Science rate lock */ fc_snprintf(cbuf, sizeof(cbuf), _("Lock")); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= TTF_STYLE_BOLD; pBuf = create_checkbox(pWindow->dst, @@ -2082,7 +2082,7 @@ void economy_report_dialog_popup(bool make_modal) 0, 0, pBackground->w - 1, pBackground->h - 1, get_theme_color(COLOR_THEME_ECONOMYDLG_FRAME)); - pstr = create_utf8_str(NULL, 0, adj_font(10)); + pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT); pstr->style |= (SF_CENTER|TTF_STYLE_BOLD); pstr->bgcol = (SDL_Color) {0, 0, 0, 0}; @@ -2983,7 +2983,7 @@ static void popup_change_research_dialog(void) } } - pstr = create_utf8_str(NULL, 0, adj_font(10)); + pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD | SF_CENTER); count = 0; @@ -3172,7 +3172,7 @@ static void popup_change_research_goal_dialog(void) } } - pstr = create_utf8_str(NULL, 0, adj_font(10)); + pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD | SF_CENTER); /* collect all techs which are reachable in under 11 steps diff --git a/client/gui-sdl2/themes.c b/client/gui-sdl2/themes.c index 96d24ff240..23fdd442fa 100644 --- a/client/gui-sdl2/themes.c +++ b/client/gui-sdl2/themes.c @@ -28,6 +28,7 @@ #include "string_vector.h" /* client/gui-sdl2 */ +#include "gui_main.h" #include "themespec.h" #include "themes_common.h" @@ -46,7 +47,7 @@ void gui_load_theme(const char *directory, const char *theme_name) return; } - /* free previous loaded theme, if any */ + /* Free previous loaded theme, if any */ theme_free(theme); theme = NULL; @@ -55,6 +56,8 @@ void gui_load_theme(const char *directory, const char *theme_name) themespec_try_read(buf); theme_load_sprites(theme); + + update_font_from_theme(theme_default_font_size(theme)); } /***************************************************************************** diff --git a/client/gui-sdl2/themespec.c b/client/gui-sdl2/themespec.c index e8d0ef0fd1..0d3b8c8f16 100644 --- a/client/gui-sdl2/themespec.c +++ b/client/gui-sdl2/themespec.c @@ -164,7 +164,7 @@ const char *theme_get_name(const struct theme *t) /**************************************************************************** Return the path within the data directories where the font file can be - found. (It is left up to the GUI code to load and unload this file.) + found. (It is left up to the GUI code to load and unload this file.) ****************************************************************************/ const char *theme_font_filename(const struct theme *t) { diff --git a/client/gui-sdl2/widget_button.h b/client/gui-sdl2/widget_button.h index abd06cc1a8..10647e9e56 100644 --- a/client/gui-sdl2/widget_button.h +++ b/client/gui-sdl2/widget_button.h @@ -25,6 +25,13 @@ iPtsize), \ flags) +#define create_themeicon_button_from_chars_fonto(icon_theme, pdest, \ + char_string, fonto, flags) \ + create_themeicon_button(icon_theme, pdest, \ + create_utf8_from_char_fonto(char_string, \ + fonto), \ + flags) + struct widget *create_icon_button(SDL_Surface *pIcon, struct gui_layer *pDest, utf8_str *pstr, Uint32 flags); diff --git a/client/gui-sdl2/widget_combo.c b/client/gui-sdl2/widget_combo.c index fa8b58a93c..334423f94f 100644 --- a/client/gui-sdl2/widget_combo.c +++ b/client/gui-sdl2/widget_combo.c @@ -161,8 +161,8 @@ void combo_popup(struct widget *combo) /* Labels. */ strvec_iterate(combo->data.vector, string) { - label = create_iconlabel_from_chars(NULL, window->dst, string, - adj_font(10), WF_RESTORE_BACKGROUND); + label = create_iconlabel_from_chars(NULL, window->dst, string, 0, + WF_RESTORE_BACKGROUND); label->action = combo_menu_item_callback; label->data.widget = combo; set_wstate(label, FC_WS_NORMAL); diff --git a/client/gui-sdl2/widget_edit.h b/client/gui-sdl2/widget_edit.h index 919ee8bfb1..f70bc185f8 100644 --- a/client/gui-sdl2/widget_edit.h +++ b/client/gui-sdl2/widget_edit.h @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 2006 - The Freeciv Project This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,6 +26,11 @@ enum Edit_Return_Codes { create_utf8_from_char(pCharString, iPtsize), \ length, flags) +#define create_edit_from_chars_fonto(background, pdest, char_string, fonto, length, flags) \ + create_edit(background, pdest, \ + create_utf8_from_char_fonto(char_string, fonto), \ + length, flags) + #define edit(pEdit) edit_field(pEdit) struct widget *create_edit(SDL_Surface *pBackground, struct gui_layer *pDest, diff --git a/client/gui-sdl2/widget_label.h b/client/gui-sdl2/widget_label.h index 930a27f41e..45b02ea303 100644 --- a/client/gui-sdl2/widget_label.h +++ b/client/gui-sdl2/widget_label.h @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 2006 - The Freeciv Project This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,6 +17,9 @@ #define create_iconlabel_from_chars(picon, pdest, chars, ptsize, flags) \ create_iconlabel(picon, pdest, create_utf8_from_char(chars, ptsize), flags) +#define create_iconlabel_from_chars_fonto(picon, pdest, chars, fonto, flags) \ + create_iconlabel(picon, pdest, create_utf8_from_char_fonto(chars, fonto), flags) + #define create_active_iconlabel(pBuf, pDest, pstr, pString, pCallback) \ do { \ pstr = create_utf8_from_char(pString, 10); \ diff --git a/client/gui-sdl2/wldlg.c b/client/gui-sdl2/wldlg.c index 4512c41f52..15cfb8f312 100644 --- a/client/gui-sdl2/wldlg.c +++ b/client/gui-sdl2/wldlg.c @@ -234,13 +234,15 @@ static void add_target_to_worklist(struct widget *pTarget) worklist_append(&pEditor->worklist_copy, &prod); - /* create widget entry */ + /* Create widget entry */ if (VUT_UTYPE == prod.kind) { - pstr = create_utf8_from_char(utype_name_translation(prod.value.utype), adj_font(10)); + pstr = create_utf8_from_char_fonto(utype_name_translation(prod.value.utype), + FONTO_DEFAULT); } else { - pstr = create_utf8_from_char(city_improvement_name_translation(pEditor->pCity, + pstr = create_utf8_from_char_fonto( + city_improvement_name_translation(pEditor->pCity, prod.value.building), - adj_font(10)); + FONTO_DEFAULT); } pstr->style |= SF_CENTER; @@ -694,20 +696,20 @@ static void add_global_worklist(struct widget *pWidget) worklist_append(&pEditor->worklist_copy, &pWorkList->entries[count]); - /* create widget */ + /* Create widget */ if (VUT_UTYPE == pWorkList->entries[count].kind) { pBuf = create_iconlabel(NULL, pWidget->dst, - create_utf8_from_char( + create_utf8_from_char_fonto( utype_name_translation(pWorkList->entries[count].value.utype), - adj_font(10)), + FONTO_DEFAULT), (WF_RESTORE_BACKGROUND|WF_FREE_DATA)); pBuf->ID = MAX_ID - cid_encode_unit(pWorkList->entries[count].value.utype); } else { pBuf = create_iconlabel(NULL, pWidget->dst, - create_utf8_from_char( + create_utf8_from_char_fonto( city_improvement_name_translation(pEditor->pCity, pWorkList->entries[count].value.building), - adj_font(10)), + FONTO_DEFAULT), (WF_RESTORE_BACKGROUND|WF_FREE_DATA)); pBuf->ID = MAX_ID - cid_encode_building(pWorkList->entries[count].value.building); } @@ -792,24 +794,26 @@ static void set_global_worklist(struct widget *pWidget) worklist_copy(&pEditor->worklist_copy, &wl); /* --------------------------------- */ - /* create new widget list */ + /* Create new widget list */ for (count = 0; count < MAX_LEN_WORKLIST; count++) { - /* end of list */ + /* End of list */ if (!worklist_peek_ith(&pEditor->worklist_copy, &target, count)) { break; } if (VUT_UTYPE == target.kind) { pBuf = create_iconlabel(NULL, pWidget->dst, - create_utf8_from_char(utype_name_translation(target.value.utype), - adj_font(10)), + create_utf8_from_char_fonto( + utype_name_translation(target.value.utype), + FONTO_DEFAULT), (WF_RESTORE_BACKGROUND|WF_FREE_DATA)); pBuf->ID = MAX_ID - B_LAST - utype_number(target.value.utype); } else { pBuf = create_iconlabel(NULL, pWidget->dst, - create_utf8_from_char(city_improvement_name_translation(pEditor->pCity, + create_utf8_from_char_fonto( + city_improvement_name_translation(pEditor->pCity, target.value.building), - adj_font(10)), + FONTO_DEFAULT), (WF_RESTORE_BACKGROUND|WF_FREE_DATA)); pBuf->ID = MAX_ID - improvement_number(target.value.building); } @@ -1129,14 +1133,14 @@ void popup_worklist_editor(struct city *pCity, struct global_worklist *gwl) fc_snprintf(cbuf, sizeof(cbuf), /* TRANS: length of worklist */ PL_("( %d entry )", "( %d entries )", len), len); - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->bgcol = (SDL_Color) {0, 0, 0, 0}; pBuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); pEditor->pWorkList_Counter = pBuf; add_to_gui_list(ID_LABEL, pBuf); /* --------------------------- */ - /* create production progress label or rename worklist edit */ + /* Create production progress label or rename worklist edit */ if (pCity) { /* count == cost */ /* turns == progress */ @@ -1165,7 +1169,7 @@ void popup_worklist_editor(struct city *pCity, struct global_worklist *gwl) fc_snprintf(cbuf, sizeof(cbuf), _("%s\nfinished!"), name); } } - pstr = create_utf8_from_char(cbuf, adj_font(10)); + pstr = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); pstr->style |= SF_CENTER; pBuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -1190,9 +1194,10 @@ void popup_worklist_editor(struct city *pCity, struct global_worklist *gwl) pEditor->pProduction_Progres = pBuf; add_to_gui_list(ID_LABEL, pBuf); } else { - pBuf = create_edit_from_chars(NULL, pWindow->dst, - global_worklist_name(gwl), adj_font(10), - adj_size(120), WF_RESTORE_BACKGROUND); + pBuf = create_edit_from_chars_fonto(NULL, pWindow->dst, + global_worklist_name(gwl), + FONTO_DEFAULT, + adj_size(120), WF_RESTORE_BACKGROUND); pBuf->action = rename_worklist_editor_callback; set_wstate(pBuf, FC_WS_NORMAL); @@ -1244,7 +1249,8 @@ void popup_worklist_editor(struct city *pCity, struct global_worklist *gwl) if (pCity) { /* Production Widget Label */ - pstr = create_utf8_from_char(city_production_name_translation(pCity), adj_font(10)); + pstr = create_utf8_from_char_fonto(city_production_name_translation(pCity), + FONTO_DEFAULT); turns = city_production_build_shield_cost(pCity); pstr->style |= SF_CENTER; pBuf = create_iconlabel(NULL, pWindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -1270,12 +1276,12 @@ void popup_worklist_editor(struct city *pCity, struct global_worklist *gwl) worklist_iterate(&pEditor->worklist_copy, prod) { if (VUT_UTYPE == prod.kind) { - pstr = create_utf8_from_char(utype_name_translation(prod.value.utype), - adj_font(10)); + pstr = create_utf8_from_char_fonto(utype_name_translation(prod.value.utype), + FONTO_DEFAULT); } else { - pstr = create_utf8_from_char(city_improvement_name_translation(pCity, + pstr = create_utf8_from_char_fonto(city_improvement_name_translation(pCity, prod.value.building), - adj_font(10)); + FONTO_DEFAULT); } pstr->style |= SF_CENTER; pBuf = create_iconlabel(NULL, pWindow->dst, pstr, @@ -1337,15 +1343,15 @@ void popup_worklist_editor(struct city *pCity, struct global_worklist *gwl) pLast = pEditor->pWork->pBeginWidgetList; /* --------------------------- */ - /* global worklists */ + /* Global worklists */ if (pCity) { count = 0; global_worklists_iterate(iter_gwl) { - pBuf = create_iconlabel_from_chars(NULL, pWindow->dst, - global_worklist_name(iter_gwl), - adj_font(10), - WF_RESTORE_BACKGROUND); + pBuf = create_iconlabel_from_chars_fonto(NULL, pWindow->dst, + global_worklist_name(iter_gwl), + FONTO_DEFAULT, + WF_RESTORE_BACKGROUND); set_wstate(pBuf, FC_WS_NORMAL); add_to_gui_list(MAX_ID - global_worklist_id(iter_gwl), pBuf); pBuf->string_utf8->style |= SF_CENTER; @@ -1387,7 +1393,7 @@ void popup_worklist_editor(struct city *pCity, struct global_worklist *gwl) /* ----------------------------- */ count = 0; /* Targets units and imprv. to build */ - pstr = create_utf8_str(NULL, 0, adj_font(10)); + pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT); pstr->style |= (SF_CENTER|TTF_STYLE_BOLD); pstr->bgcol = (SDL_Color) {0, 0, 0, 0}; diff --git a/data/themes/gui-sdl2/human/theme.themespec b/data/themes/gui-sdl2/human/theme.themespec index 32f0739418..9b0bb55dc9 100644 --- a/data/themes/gui-sdl2/human/theme.themespec +++ b/data/themes/gui-sdl2/human/theme.themespec @@ -15,7 +15,7 @@ font_file = "themes/gui-sdl2/human/DejaVuSans.ttf" font_file_zh_CN = "themes/gui-sdl2/human/fireflysung.ttf" font_file_ja = "themes/gui-sdl2/human/sazanami-gothic.ttf" font_file_ko = "themes/gui-sdl2/human/UnDotum.ttf" -default_font_size = 18 +default_font_size = 10 ; Below, the graphics spec files; must be somewhere (anywhere) in ; the data path. Order may be important for color allocation on -- 2.39.2