From 69a83df3935a1d434492b78a799539c813497346 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 3 Apr 2023 20:03:46 +0300 Subject: [PATCH 11/11] 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.h | 2 +- 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 | 33 +++++----- 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 | 2 +- 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 +- 29 files changed, 318 insertions(+), 231 deletions(-) diff --git a/client/gui-sdl2/action_dialog.c b/client/gui-sdl2/action_dialog.c index fa4cfadc0e..112b5c712e 100644 --- a/client/gui-sdl2/action_dialog.c +++ b/client/gui-sdl2/action_dialog.c @@ -534,7 +534,7 @@ static int spy_steal_popup(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 20934d5418..9199ced980 100644 --- a/client/gui-sdl2/chatline.c +++ b/client/gui-sdl2/chatline.c @@ -61,8 +61,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 1cdd90e9d0..1fca7d3e8c 100644 --- a/client/gui-sdl2/citydlg.c +++ b/client/gui-sdl2/citydlg.c @@ -747,7 +747,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 @@ -959,7 +959,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); @@ -1202,8 +1202,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); @@ -1417,25 +1417,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; @@ -1752,7 +1755,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; @@ -1797,7 +1800,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; @@ -1854,7 +1857,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; @@ -1902,7 +1905,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; @@ -2072,7 +2075,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; @@ -2423,14 +2426,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; @@ -3398,9 +3401,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; @@ -3714,8 +3719,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 7590af1f7a..a22b3bb2a8 100644 --- a/client/gui-sdl2/cma_fe.c +++ b/client/gui-sdl2/cma_fe.c @@ -329,8 +329,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); @@ -522,7 +523,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)); @@ -951,14 +952,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)); @@ -969,14 +971,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)); @@ -992,14 +995,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)); @@ -1018,54 +1022,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 b2a330aa86..a69b542703 100644 --- a/client/gui-sdl2/connectdlg.c +++ b/client/gui-sdl2/connectdlg.c @@ -336,7 +336,9 @@ 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; @@ -562,22 +564,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; @@ -585,15 +587,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); @@ -602,15 +604,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 5bc309a241..a03b2dd6c7 100644 --- a/client/gui-sdl2/dialogs.c +++ b/client/gui-sdl2/dialogs.c @@ -694,8 +694,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); @@ -890,8 +890,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); @@ -1707,7 +1707,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 f1bb704c2c..b66cc5213d 100644 --- a/client/gui-sdl2/diplodlg.c +++ b/client/gui-sdl2/diplodlg.c @@ -636,7 +636,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.h b/client/gui-sdl2/gui_main.h index 3929e8efbf..277245f2a4 100644 --- a/client/gui-sdl2/gui_main.h +++ b/client/gui-sdl2/gui_main.h @@ -125,7 +125,7 @@ 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 */ +/* 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 e6755737fb..5e04692f7e 100644 --- a/client/gui-sdl2/gui_string.c +++ b/client/gui-sdl2/gui_string.c @@ -155,6 +155,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. @@ -191,6 +205,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. @@ -518,6 +544,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 a495fbb524..271a482210 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 75606ff6a3..434b28a42e 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) { @@ -692,7 +693,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 */ @@ -749,9 +750,10 @@ void popup_unit_info(Unit_type_id type_id) 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, _("Units"), adj_font(10), 0); + /* Toggle techs list button */ + 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) { @@ -1659,7 +1661,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))); @@ -1954,8 +1956,8 @@ 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)); + /* --- Create scrollable advance list on the left side ---*/ + pstr = create_utf8_str_fonto(NULL, 0, FONTO_DEFAULT); pstr->style |= (TTF_STYLE_BOLD | SF_CENTER); tech_count = 0; @@ -1989,11 +1991,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 158447cd56..2520245ac6 100644 --- a/client/gui-sdl2/inteldlg.c +++ b/client/gui-sdl2/inteldlg.c @@ -317,7 +317,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 256688ed1f..bd9c375d45 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 1b6cc1cd83..f2b4f8125a 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 51185aeb68..340c3b5299 100644 --- a/client/gui-sdl2/menu.c +++ b/client/gui-sdl2/menu.c @@ -408,7 +408,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); /* --------- */ @@ -422,7 +422,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); /* --------- */ @@ -687,7 +687,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); /* --------- */ @@ -699,7 +699,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); @@ -712,7 +712,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); /* --------- */ @@ -725,7 +725,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); @@ -738,7 +738,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); /* --------- */ @@ -751,7 +751,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); @@ -765,7 +765,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; @@ -779,7 +779,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); /* --------- */ @@ -792,7 +792,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; @@ -807,7 +807,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); @@ -821,7 +821,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); @@ -837,7 +837,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; @@ -851,7 +851,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); @@ -866,7 +866,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); @@ -881,7 +881,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); /* --------- */ @@ -894,7 +894,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 0697536423..75fa74ea5a 100644 --- a/client/gui-sdl2/messagewin.c +++ b/client/gui-sdl2/messagewin.c @@ -59,7 +59,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 5cf027a512..719007a7eb 100644 --- a/client/gui-sdl2/plrdlg.c +++ b/client/gui-sdl2/plrdlg.c @@ -460,7 +460,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)); @@ -478,7 +478,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); @@ -524,7 +524,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}; @@ -743,7 +743,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 d0edc236d9..4a6ef05a35 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 43c63d89b0..466b696cd0 100644 --- a/client/gui-sdl2/themes.c +++ b/client/gui-sdl2/themes.c @@ -42,7 +42,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; diff --git a/client/gui-sdl2/themespec.c b/client/gui-sdl2/themespec.c index 58d0ee78ab..f28f59a842 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 fd058d964f..3ef9aba09a 100644 --- a/client/gui-sdl2/widget_combo.c +++ b/client/gui-sdl2/widget_combo.c @@ -162,8 +162,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 d758516d9b..cbea7c3556 100644 --- a/client/gui-sdl2/wldlg.c +++ b/client/gui-sdl2/wldlg.c @@ -235,13 +235,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; @@ -695,20 +697,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); } @@ -793,24 +795,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); } @@ -1130,14 +1134,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 */ @@ -1166,7 +1170,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); @@ -1191,9 +1195,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); @@ -1245,7 +1250,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); @@ -1271,12 +1277,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, @@ -1338,15 +1344,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; @@ -1388,7 +1394,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 85812ed7db..ff837b4ba7 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