From ffd61e7e80f3b6179614dea20d27cb6721d06371 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 3 Apr 2023 19:13:06 +0300 Subject: [PATCH 19/19] 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 | 49 ++++++------- client/gui-sdl2/cityrep.c | 34 ++++----- client/gui-sdl2/cma_fe.c | 56 +++++++-------- client/gui-sdl2/connectdlg.c | 24 +++---- client/gui-sdl2/dialogs.c | 14 ++-- 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 | 24 ++++--- client/gui-sdl2/inteldlg.c | 2 +- client/gui-sdl2/mapctrl.c | 24 +++---- client/gui-sdl2/mapview.c | 4 +- client/gui-sdl2/menu.c | 78 ++++++++++----------- client/gui-sdl2/messagewin.c | 3 +- client/gui-sdl2/plrdlg.c | 8 +-- client/gui-sdl2/repodlgs.c | 68 +++++++++--------- 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 | 5 ++ client/gui-sdl2/widget_label.h | 3 + client/gui-sdl2/wldlg.c | 80 +++++++++++----------- data/themes/gui-sdl2/human/theme.themespec | 2 +- 30 files changed, 325 insertions(+), 243 deletions(-) diff --git a/client/gui-sdl2/action_dialog.c b/client/gui-sdl2/action_dialog.c index 7a93a44bd3..9b42dc0bb5 100644 --- a/client/gui-sdl2/action_dialog.c +++ b/client/gui-sdl2/action_dialog.c @@ -451,7 +451,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 9f60ad5a91..655b062790 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_dialog *users_dlg; struct advanced_dialog *chat_dlg; diff --git a/client/gui-sdl2/citydlg.c b/client/gui-sdl2/citydlg.c index 785e9ab93e..29f41932b3 100644 --- a/client/gui-sdl2/citydlg.c +++ b/client/gui-sdl2/citydlg.c @@ -757,7 +757,7 @@ static void create_present_supported_units_widget_list(struct unit_list *units) surf = 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; buf = create_icon2(surf, pwindow->dst, WF_FREE_THEME @@ -974,7 +974,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); @@ -1225,8 +1225,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); @@ -1435,7 +1435,7 @@ static int sell_imprvm_dlg_callback(struct widget *impr) area = pwindow->area; - /* create text label */ + /* Create text label */ id = MAX_ID - 3000 - impr->id; price = impr_sell_gold(improvement_by_number(id)); @@ -1444,25 +1444,26 @@ static int sell_imprvm_dlg_callback(struct widget *impr) city_improvement_name_translation(pcity_dlg->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); label = create_iconlabel(NULL, pwindow->dst, pstr, 0); add_to_gui_list(ID_LABEL, label); - /* create cancel button */ + /* Create cancel button */ cancel_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); cancel_button->action = sell_imprvm_dlg_cancel_callback; cancel_button->key = SDLK_ESCAPE; set_wstate(cancel_button, FC_WS_NORMAL); add_to_gui_list(ID_BUTTON, cancel_button); /* create ok button */ - ok_button = create_themeicon_button_from_chars(current_theme->small_ok_icon, - pwindow->dst, _("Sell"), - adj_font(10), 0); + ok_button = create_themeicon_button_from_chars_fonto(current_theme->small_ok_icon, + pwindow->dst, _("Sell"), + FONTO_DEFAULT, 0); ok_button->data.ptr = (void *)impr; ok_button->size.w = cancel_button->size.w; ok_button->action = sell_imprvm_dlg_ok_callback; @@ -1782,7 +1783,7 @@ static void redraw_misc_city_dialog(struct widget *city_window, 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; @@ -1827,7 +1828,7 @@ static void redraw_supported_units_city_dialog(struct widget *city_window, 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; @@ -1884,7 +1885,7 @@ static void redraw_army_city_dialog(struct widget *city_window, 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; @@ -1932,7 +1933,7 @@ static void redraw_info_city_dialog(struct widget *city_window, 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; @@ -2100,7 +2101,7 @@ static void redraw_happiness_city_dialog(const struct widget *city_window, 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; @@ -2459,7 +2460,7 @@ static void redraw_city_dialog(struct city *pcity) /* ================================================================= */ 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; @@ -3430,10 +3431,11 @@ static void rebuild_imprm_list(struct city *pcity) add_dock = pcity_dlg->add_point; buf = last = add_dock; - /* alloc 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; @@ -3747,8 +3749,9 @@ void real_city_dialog_popup(struct city *pcity) add_to_gui_list(ID_CITY_DLG_NEXT_BUTTON, buf); /* -------- */ - buf = create_edit_from_chars(NULL, pwindow->dst, city_name_get(pcity), - adj_font(10), adj_size(200), WF_RESTORE_BACKGROUND); + buf = create_edit_from_chars_fonto(NULL, pwindow->dst, city_name_get(pcity), + FONTO_DEFAULT, adj_size(200), + WF_RESTORE_BACKGROUND); buf->action = new_name_city_dlg_callback; buf->size.x = area.x + (area.w - buf->size.w) / 2; buf->size.y = area.y + area.h - buf->size.h - adj_size(2); diff --git a/client/gui-sdl2/cityrep.c b/client/gui-sdl2/cityrep.c index b14dc62196..05cded9bf0 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; text1 = create_text_surf_from_utf8(pstr); @@ -323,7 +323,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); @@ -350,7 +350,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, @@ -364,7 +364,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, @@ -390,7 +390,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; @@ -406,7 +406,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, @@ -420,7 +420,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); @@ -433,7 +433,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, @@ -447,7 +447,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, @@ -461,7 +461,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, @@ -476,7 +476,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, @@ -490,7 +490,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); @@ -504,7 +504,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, @@ -518,7 +518,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, @@ -562,8 +562,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); @@ -587,7 +587,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 702225ea5f..e0dd19e11e 100644 --- a/client/gui-sdl2/cma_fe.c +++ b/client/gui-sdl2/cma_fe.c @@ -331,9 +331,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); @@ -528,7 +528,7 @@ static void popup_load_del_presets_dialog(bool load, struct widget *button) /* ---------- */ 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; buf = create_iconlabel(NULL, pwindow->dst, pstr, (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE)); @@ -957,14 +957,14 @@ void popup_city_cma_dialog(struct city *pcity) text[i] = create_text_surf_from_utf8(pstr); text_w = MAX(text_w, text[i]->w); - /* minimal label */ + /* Minimal label */ buf = 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, buf); - /* minimal scrollbar */ + /* Minimal scrollbar */ buf = create_horizontal(current_theme->horiz, pwindow->dst, adj_size(30), (WF_RESTORE_BACKGROUND)); @@ -975,14 +975,14 @@ void popup_city_cma_dialog(struct city *pcity) add_to_gui_list(ID_SCROLLBAR, buf); - /* factor label */ + /* Factor label */ buf = 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, buf); - /* factor scrollbar */ + /* Factor scrollbar */ buf = create_horizontal(current_theme->horiz, pwindow->dst, adj_size(30), (WF_RESTORE_BACKGROUND)); @@ -998,14 +998,14 @@ void popup_city_cma_dialog(struct city *pcity) text[O_LAST] = create_text_surf_from_utf8(pstr); FREEUTF8STR(pstr); - /* happy factor label */ + /* Happy factor label */ buf = 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, buf); - /* happy factor scrollbar */ + /* Happy factor scrollbar */ buf = create_horizontal(current_theme->horiz, pwindow->dst, adj_size(30), (WF_RESTORE_BACKGROUND)); @@ -1025,54 +1025,54 @@ void popup_city_cma_dialog(struct city *pcity) buf->action = toggle_cma_celebrating_callback; add_to_gui_list(ID_CHECKBOX, buf); - /* save as ... */ + /* Save as ... */ buf = create_themeicon(current_theme->save_icon, pwindow->dst, WF_RESTORE_BACKGROUND |WF_WIDGET_HAS_INFO_LABEL); buf->action = save_cma_callback; - buf->info_label = create_utf8_from_char(_("Save settings as..."), - adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(_("Save settings as..."), + FONTO_DEFAULT); add_to_gui_list(ID_ICON, buf); - /* load settings */ + /* Load settings */ buf = create_themeicon(current_theme->load_icon, pwindow->dst, WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL); buf->action = load_cma_callback; - buf->info_label = create_utf8_from_char(_("Load settings"), - adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(_("Load settings"), + FONTO_DEFAULT); add_to_gui_list(ID_ICON, buf); - /* del settings */ + /* Del settings */ buf = create_themeicon(current_theme->delete_icon, pwindow->dst, WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL); buf->action = del_cma_callback; - buf->info_label = create_utf8_from_char(_("Delete settings"), - adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(_("Delete settings"), + FONTO_DEFAULT); add_to_gui_list(ID_ICON, buf); - /* run cma */ + /* Run cma */ buf = create_themeicon(current_theme->qprod_icon, pwindow->dst, WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL); buf->action = run_cma_callback; - buf->info_label = create_utf8_from_char(_("Control city"), adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(_("Control city"), FONTO_DEFAULT); add_to_gui_list(ID_ICON, buf); - /* run cma onece */ + /* Run cma onece */ buf = create_themeicon(current_theme->find_city_icon, pwindow->dst, WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL); buf->action = run_cma_once_callback; - buf->info_label = create_utf8_from_char(_("Apply once"), adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(_("Apply once"), FONTO_DEFAULT); add_to_gui_list(ID_ICON, buf); - /* del settings */ + /* Del settings */ buf = create_themeicon(current_theme->support_icon, pwindow->dst, WF_RESTORE_BACKGROUND | WF_WIDGET_HAS_INFO_LABEL); buf->action = stop_cma_callback; - buf->info_label = create_utf8_from_char(_("Release city"), adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(_("Release city"), FONTO_DEFAULT); add_to_gui_list(ID_ICON, buf); diff --git a/client/gui-sdl2/connectdlg.c b/client/gui-sdl2/connectdlg.c index 6d51add8ab..cb92c1140a 100644 --- a/client/gui-sdl2/connectdlg.c +++ b/client/gui-sdl2/connectdlg.c @@ -325,8 +325,8 @@ void popup_connection_dialog(bool lan_scan) server->host, server->port, server->version, _(server->state), Q_("?header:Players"), server->nplayers, server->message); - new_widget = create_iconlabel_from_chars(NULL, pwindow->dst, cbuf, - adj_font(10), + new_widget = create_iconlabel_from_chars_fonto(NULL, pwindow->dst, cbuf, + FONTO_DEFAULT, WF_FREE_STRING|WF_DRAW_TEXT_LABEL_WITH_SPACE|WF_RESTORE_BACKGROUND); new_widget->string_utf8->style |= SF_CENTER; @@ -553,22 +553,22 @@ void popup_join_game_dialog(void) connect_dlg = fc_calloc(1, sizeof(struct small_dialog)); - /* window */ + /* Window */ pwindow = create_window_skeleton(NULL, NULL, 0); add_to_gui_list(ID_WINDOW, pwindow); connect_dlg->end_widget_list = 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); buf = create_iconlabel(NULL, pwindow->dst, plrname, (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE)); add_to_gui_list(ID_LABEL, buf); area.h += buf->size.h + adj_size(20); - /* player name edit */ + /* Player name edit */ buf = create_edit_from_chars(NULL, pwindow->dst, user_name, adj_font(14), adj_size(210), (WF_RESTORE_BACKGROUND|WF_FREE_DATA)); @@ -577,15 +577,15 @@ void popup_join_game_dialog(void) add_to_gui_list(ID_PLAYER_NAME_EDIT, buf); area.h += buf->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); buf = create_iconlabel(NULL, pwindow->dst, srvname, (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE)); add_to_gui_list(ID_LABEL, buf); area.h += buf->size.h + adj_size(5); - /* server name edit */ + /* Server name edit */ buf = create_edit_from_chars(NULL, pwindow->dst, server_host, adj_font(14), adj_size(210), WF_RESTORE_BACKGROUND); @@ -594,15 +594,15 @@ void popup_join_game_dialog(void) add_to_gui_list(ID_SERVER_NAME_EDIT, buf); area.h += buf->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); buf = create_iconlabel(NULL, pwindow->dst, port_nr, (WF_RESTORE_BACKGROUND|WF_DRAW_TEXT_LABEL_WITH_SPACE)); add_to_gui_list(ID_LABEL, buf); area.h += buf->size.h + adj_size(5); - /* port edit */ + /* Port edit */ fc_snprintf(port_str, sizeof(port_str), "%d", server_port); buf = create_edit_from_chars(NULL, pwindow->dst, port_str, adj_font(14), diff --git a/client/gui-sdl2/dialogs.c b/client/gui-sdl2/dialogs.c index eda42cdb36..43b4412f15 100644 --- a/client/gui-sdl2/dialogs.c +++ b/client/gui-sdl2/dialogs.c @@ -711,8 +711,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); @@ -722,7 +722,7 @@ void popup_unit_upgrade_dlg(struct unit *punit, bool city) area.w = MAX(area.w, text->w + adj_size(20)); area.h += (text->h + adj_size(10)); - /* cancel button */ + /* Cancel button */ buf = create_themeicon_button_from_chars(current_theme->cancel_icon, pwindow->dst, _("Cancel"), adj_font(12), 0); @@ -909,8 +909,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); @@ -920,7 +920,7 @@ void popup_unit_disband_dlg(struct unit *punit, bool city) area.w = MAX(area.w, text->w + adj_size(20)); area.h += (text->h + adj_size(10)); - /* cancel button */ + /* Cancel button */ buf = create_themeicon_button_from_chars(current_theme->cancel_icon, pwindow->dst, _("Cancel"), adj_font(12), 0); @@ -1741,7 +1741,7 @@ void popup_advanced_terrain_dialog(struct tile *ptile, Uint16 pos_x, Uint16 pos_ add_to_gui_list(ID_TERRAIN_ADV_DLG_EXIT_BUTTON, buf); /* ---------- */ - 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; buf = create_iconlabel(NULL, pwindow->dst, pstr, diff --git a/client/gui-sdl2/diplodlg.c b/client/gui-sdl2/diplodlg.c index f02c08f5bb..b94cc68809 100644 --- a/client/gui-sdl2/diplodlg.c +++ b/client/gui-sdl2/diplodlg.c @@ -659,7 +659,7 @@ static struct advanced_dialog *popup_diplomatic_objects(struct player *pplayer0, count++; buf = 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)); buf->data.cont = cont; buf->action = gold_callback; diff --git a/client/gui-sdl2/finddlg.c b/client/gui-sdl2/finddlg.c index bea72c2730..a47dbf07bd 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 5dfd42ee56..6576281d24 100644 --- a/client/gui-sdl2/gui_main.c +++ b/client/gui-sdl2/gui_main.c @@ -1243,6 +1243,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 c5b41f5342..ecf8e4e49b 100644 --- a/client/gui-sdl2/gui_main.h +++ b/client/gui-sdl2/gui_main.h @@ -124,7 +124,9 @@ Uint16 gui_event_loop(void *data, void (*loop_action)(void *data), Uint16 (*mouse_motion_handler)(SDL_MouseMotionEvent *motion_event, void *data)); -/* 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 634bc77069..9ae5c7bcc9 100644 --- a/client/gui-sdl2/gui_string.c +++ b/client/gui-sdl2/gui_string.c @@ -153,6 +153,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. @@ -189,6 +203,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. @@ -517,6 +543,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 60eff8d53f..1ffadadfb5 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 514a2bd0cb..d9d8b34bde 100644 --- a/client/gui-sdl2/gui_tilespec.c +++ b/client/gui-sdl2/gui_tilespec.c @@ -381,11 +381,11 @@ void setup_auxiliary_tech_icons(void) { SDL_Color bg_color = {255, 255, 255, 136}; SDL_Surface *surf; - 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 */ surf = create_surf(adj_size(50), adj_size(50), SDL_SWSURFACE); SDL_FillRect(surf, NULL, map_rgba(surf->format, bg_color)); create_frame(surf, diff --git a/client/gui-sdl2/helpdlg.c b/client/gui-sdl2/helpdlg.c index 0e5c51bee1..ebf3ffef66 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) /* ------------------ */ dock = close_button; - 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 */ - list_toggle_button = create_themeicon_button_from_chars(current_theme->up_icon, + list_toggle_button = create_themeicon_button_from_chars_fonto( + current_theme->up_icon, pwindow->dst, _("Improvements"), - adj_font(10), 0); + FONTO_DEFAULT, 0); #if 0 list_toggle_button->action = toggle_full_tree_mode_in_help_dlg_callback; if (store->show_tree) { @@ -690,7 +691,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 */ @@ -748,9 +749,11 @@ void popup_unit_info(Unit_type_id type_id) } /* Toggle techs list button */ - list_toggle_button = create_themeicon_button_from_chars(current_theme->up_icon, + list_toggle_button = create_themeicon_button_from_chars_fonto( + current_theme->up_icon, pwindow->dst, - _("Units"), adj_font(10), 0); + _("Units"), + FONTO_DEFAULT, 0); #if 0 list_toggle_button->action = toggle_full_tree_mode_in_help_dlg_callback; if (store->show_tree) { @@ -1656,7 +1659,7 @@ static struct widget *create_tech_tree(Tech_type_id tech, int width, SDL_Surface *surf; struct widget *dock = store->dock; - 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))); @@ -1952,7 +1955,7 @@ void popup_tech_info(Tech_type_id tech) dock = close_button; /* --- 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; @@ -1987,10 +1990,11 @@ void popup_tech_info(Tech_type_id tech) } /* Toggle techs list button */ - list_toggle_button = create_themeicon_button_from_chars(current_theme->up_icon, + list_toggle_button = create_themeicon_button_from_chars_fonto( + current_theme->up_icon, pwindow->dst, _("Advances"), - adj_font(10), 0); + FONTO_DEFAULT, 0); list_toggle_button->action = toggle_full_tree_mode_in_help_dlg_callback; if (store->show_tree) { set_wstate(list_toggle_button, FC_WS_NORMAL); diff --git a/client/gui-sdl2/inteldlg.c b/client/gui-sdl2/inteldlg.c index 2da2ea1cab..b2c7adaacf 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_primary_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 467ce0196f..3c8c589852 100644 --- a/client/gui-sdl2/mapctrl.c +++ b/client/gui-sdl2/mapctrl.c @@ -2784,33 +2784,33 @@ void popup_newcity_dialog(struct unit *punit, const char *suggest_name) area = pwindow->area; - /* create ok button */ + /* Create ok button */ ok_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); ok_button->action = newcity_ok_callback; ok_button->key = SDLK_RETURN; ok_button->data.tile = unit_tile(punit); area.h += ok_button->size.h; - /* create cancel button */ + /* Create cancel button */ cancel_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); cancel_button->action = newcity_cancel_callback; cancel_button->key = SDLK_ESCAPE; cancel_button->data.tile = unit_tile(punit); - /* correct sizes */ + /* Correct sizes */ cancel_button->size.w += adj_size(5); ok_button->size.w = cancel_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_fonto(_("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); label = create_iconlabel(NULL, pwindow->dst, pstr, diff --git a/client/gui-sdl2/mapview.c b/client/gui-sdl2/mapview.c index ce4113c464..07ae2a8294 100644 --- a/client/gui-sdl2/mapview.c +++ b/client/gui-sdl2/mapview.c @@ -565,7 +565,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) { @@ -575,7 +575,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 ffa99ebb13..38310419fc 100644 --- a/client/gui-sdl2/menu.c +++ b/client/gui-sdl2/menu.c @@ -415,7 +415,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_SPACE; add_to_gui_list(ID_UNIT_ORDER_DONE, buf); /* --------- */ @@ -429,7 +429,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_w; add_to_gui_list(ID_UNIT_ORDER_WAIT, buf); /* --------- */ @@ -442,7 +442,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_n; buf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_NUKE, buf); @@ -456,7 +456,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_d; add_to_gui_list(ID_UNIT_ORDER_DIPLOMAT_DLG, buf); /* --------- */ @@ -468,7 +468,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_d; buf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_DISBAND, buf); @@ -481,7 +481,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_u; buf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_UPGRADE, buf); @@ -494,7 +494,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_o; buf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_CONVERT, buf); @@ -508,7 +508,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_g; buf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_RETURN, buf); @@ -521,7 +521,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_t; add_to_gui_list(ID_UNIT_ORDER_GOTO_CITY, buf); /* --------- */ @@ -533,7 +533,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_t; add_to_gui_list(ID_UNIT_ORDER_AIRLIFT, buf); /* --------- */ @@ -545,7 +545,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_g; add_to_gui_list(ID_UNIT_ORDER_GOTO, buf); /* --------- */ @@ -557,7 +557,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_q; add_to_gui_list(ID_UNIT_ORDER_PATROL, buf); /* --------- */ @@ -570,7 +570,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_i; buf->mod = KMOD_CTRL; add_to_gui_list(ID_UNIT_ORDER_CONNECT_IRRIGATE, buf); @@ -589,7 +589,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_r; buf->mod = KMOD_CTRL; add_to_gui_list(ID_UNIT_ORDER_CONNECT_ROAD, buf); @@ -608,7 +608,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_l; buf->mod = KMOD_CTRL; add_to_gui_list(ID_UNIT_ORDER_CONNECT_RAILROAD, buf); @@ -622,7 +622,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_x; add_to_gui_list(ID_UNIT_ORDER_AUTO_EXPLORE, buf); /* --------- */ @@ -635,7 +635,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_a; add_to_gui_list(ID_UNIT_ORDER_AUTO_SETTLER, buf); /* --------- */ @@ -648,7 +648,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_s; buf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_WAKEUP_OTHERS, buf); @@ -662,7 +662,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->mod = KMOD_SHIFT; buf->key = SDLK_t; add_to_gui_list(ID_UNIT_ORDER_UNLOAD_TRANSPORTER, buf); @@ -675,7 +675,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_l; add_to_gui_list(ID_UNIT_ORDER_BOARD, buf); /* --------- */ @@ -687,7 +687,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_u; add_to_gui_list(ID_UNIT_ORDER_DEBOARD, buf); /* --------- */ @@ -700,7 +700,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_h; add_to_gui_list(ID_UNIT_ORDER_HOMECITY, buf); /* --------- */ @@ -712,7 +712,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_p; buf->mod = KMOD_SHIFT; add_to_gui_list(ID_UNIT_ORDER_PILLAGE, buf); @@ -725,7 +725,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_s; add_to_gui_list(ID_UNIT_ORDER_SENTRY, buf); /* --------- */ @@ -738,7 +738,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_n; order_fallout_button = buf; add_to_gui_list(ID_UNIT_ORDER_FALLOUT, buf); @@ -752,7 +752,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_j; add_to_gui_list(ID_UNIT_ORDER_PARADROP, buf); /* --------- */ @@ -765,7 +765,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_p; order_pollution_button = buf; add_to_gui_list(ID_UNIT_ORDER_POLLUTION, buf); @@ -779,7 +779,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_e; buf->mod = KMOD_SHIFT; order_airbase_button = buf; @@ -793,7 +793,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_f; add_to_gui_list(ID_UNIT_ORDER_FORTIFY, buf); /* --------- */ @@ -806,7 +806,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_f; buf->mod = KMOD_SHIFT; order_fortress_button = buf; @@ -821,7 +821,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_o; order_transform_button = buf; add_to_gui_list(ID_UNIT_ORDER_TRANSFORM, buf); @@ -835,7 +835,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_m; add_to_gui_list(ID_UNIT_ORDER_MINE, buf); @@ -851,7 +851,7 @@ void create_units_order_widgets(void) set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; buf->key = SDLK_i; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); add_to_gui_list(ID_UNIT_ORDER_IRRIGATE, buf); order_irrigation_button = buf; @@ -867,7 +867,7 @@ void create_units_order_widgets(void) buf->action = unit_order_callback; buf->key = SDLK_i; buf->mod = KMOD_SHIFT; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); add_to_gui_list(ID_UNIT_ORDER_CULTIVATE, buf); order_cultivate_button = buf; @@ -883,7 +883,7 @@ void create_units_order_widgets(void) buf->action = unit_order_callback; buf->key = SDLK_m; buf->mod = KMOD_SHIFT; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); add_to_gui_list(ID_UNIT_ORDER_PLANT, buf); order_plant_button = buf; @@ -897,7 +897,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_r; add_to_gui_list(ID_UNIT_ORDER_TRADE_ROUTE, buf); @@ -912,7 +912,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_r; add_to_gui_list(ID_UNIT_ORDER_ROAD, buf); @@ -927,7 +927,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_b; add_to_gui_list(ID_UNIT_ORDER_BUILD_WONDER, buf); /* --------- */ @@ -940,7 +940,7 @@ void create_units_order_widgets(void) | WF_WIDGET_HAS_INFO_LABEL); set_wstate(buf, FC_WS_NORMAL); buf->action = unit_order_callback; - buf->info_label = create_utf8_from_char(cbuf, adj_font(10)); + buf->info_label = create_utf8_from_char_fonto(cbuf, FONTO_DEFAULT); buf->key = SDLK_b; add_to_gui_list(ID_UNIT_ORDER_BUILD_CITY, buf); diff --git a/client/gui-sdl2/messagewin.c b/client/gui-sdl2/messagewin.c index 3455563c8d..6dcaea7316 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_dialog *msg_dlg = NULL; diff --git a/client/gui-sdl2/plrdlg.c b/client/gui-sdl2/plrdlg.c index 138f87c038..ce61b0ef24 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); logo = get_nation_flag_surface(nation_of_player(pplayer)); @@ -452,7 +452,7 @@ void popup_players_dialog(bool raise) buf->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); logo = create_text_surf_from_utf8(pstr); @@ -498,7 +498,7 @@ void popup_players_dialog(bool raise) buf->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; logo = get_nation_flag_surface(nation_of_player(pplayer)); diff --git a/client/gui-sdl2/repodlgs.c b/client/gui-sdl2/repodlgs.c index 9f7170cdb9..cbcb819814 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); @@ -249,7 +249,7 @@ static int popup_upgrade_unit_callback(struct widget *pwidget) area.h += (text->h + adj_size(10)); area.w = MAX(area.w, text->w + adj_size(20)); - /* cancel button */ + /* Cancel button */ buf = create_themeicon_button_from_chars(current_theme->cancel_icon, pwindow->dst, _("No"), adj_font(12), 0); @@ -373,7 +373,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; text1 = create_text_surf_from_utf8(pstr); @@ -420,10 +420,10 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, add_to_gui_list(ID_BUTTON, buf); /* ------------------------- */ - /* 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); buf = create_iconlabel(NULL, pwindow->dst, pstr, @@ -435,7 +435,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); buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -445,7 +445,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); buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -455,7 +455,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); buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -465,7 +465,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); buf = create_iconlabel(NULL, pwindow->dst, pstr, @@ -512,9 +512,9 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, name_w = MAX(buf->size.w, name_w); add_to_gui_list(MAX_ID - utype_number(i), buf); - /* 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; buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -525,9 +525,9 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, buf->size.w = text1->w + adj_size(6); add_to_gui_list(MAX_ID - utype_number(i), buf); - /* 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; buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -538,9 +538,9 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, buf->size.w = text1->w; add_to_gui_list(MAX_ID - utype_number(i), buf); - /* 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; buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -552,9 +552,9 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, buf->size.w = text1->w; add_to_gui_list(MAX_ID - utype_number(i), buf); - /* 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; buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -566,13 +566,13 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, buf->size.w = text1->w; add_to_gui_list(MAX_ID - utype_number(i), buf); - /* 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; buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -583,7 +583,7 @@ static void real_activeunits_report_dialog_update(struct units_entry *units, buf->size.w = text2->w + adj_size(6); add_to_gui_list(MAX_ID - utype_number(i), buf); - /* 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, @@ -592,7 +592,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; buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -1643,8 +1643,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); @@ -1654,7 +1654,7 @@ static int popup_sell_impr_callback(struct widget *pwidget) area.w = MAX(area.w, text->w + adj_size(20)); area.h += (text->h + adj_size(10)); - /* cancel button */ + /* Cancel button */ buf = create_themeicon_button_from_chars(current_theme->cancel_icon, pwindow->dst, _("No"), adj_font(12), 0); @@ -1971,11 +1971,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; buf = create_checkbox(pwindow->dst, @@ -2018,11 +2018,11 @@ void economy_report_dialog_popup(bool make_modal) w2 += (adj_size(5) + buf->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; buf = create_checkbox(pwindow->dst, @@ -2100,7 +2100,7 @@ void economy_report_dialog_popup(bool make_modal) 0, 0, background->w - 1, background->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}; @@ -3003,7 +3003,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; @@ -3192,7 +3192,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 5a56bcce11..05aad7ce60 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(active_theme); active_theme = NULL; @@ -55,6 +56,8 @@ void gui_load_theme(const char *directory, const char *theme_name) themespec_try_read(buf); theme_load_sprites(active_theme); + + update_font_from_theme(theme_default_font_size(active_theme)); } /*************************************************************************//** diff --git a/client/gui-sdl2/themespec.c b/client/gui-sdl2/themespec.c index 9ae585d892..ee75e2b231 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 0710996e9a..fea1d13ebf 100644 --- a/client/gui-sdl2/widget_button.h +++ b/client/gui-sdl2/widget_button.h @@ -25,6 +25,13 @@ ptsize), \ 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 *icon, 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 9a6bc4d442..e13c2fdbbf 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 4bf8a49603..85da675e98 100644 --- a/client/gui-sdl2/widget_edit.h +++ b/client/gui-sdl2/widget_edit.h @@ -26,6 +26,11 @@ enum edit_return_codes { create_utf8_from_char(char_string, ptsize), \ 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 *background, struct gui_layer *pdest, diff --git a/client/gui-sdl2/widget_label.h b/client/gui-sdl2/widget_label.h index b7dc11c738..aea2416e9d 100644 --- a/client/gui-sdl2/widget_label.h +++ b/client/gui-sdl2/widget_label.h @@ -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(buf, pdest, pstr, pstring, cb) \ do { \ pstr = create_utf8_from_char(pstring, 10); \ diff --git a/client/gui-sdl2/wldlg.c b/client/gui-sdl2/wldlg.c index b13b47b889..a573676fbc 100644 --- a/client/gui-sdl2/wldlg.c +++ b/client/gui-sdl2/wldlg.c @@ -234,13 +234,14 @@ static void add_target_to_worklist(struct widget *target) worklist_append(&editor->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(editor->pcity, + pstr = create_utf8_from_char_fonto(city_improvement_name_translation(editor->pcity, prod.value.building), - adj_font(10)); + FONTO_DEFAULT); } pstr->style |= SF_CENTER; @@ -680,14 +681,14 @@ static void add_global_worklist(struct widget *pwidget) } if (worklist_length(&editor->worklist_copy) >= MAX_LEN_WORKLIST - 1) { - /* worklist is full */ + /* Worklist is full */ return; } firstfree = worklist_length(&editor->worklist_copy); - /* copy global worklist to city worklist */ + /* Copy global worklist to city worklist */ for (count = 0 ; count < worklist_length(pworklist); count++) { - /* global worklist can have targets unavilable in current state of game + /* Global worklist can have targets unavilable in current state of game then we must remove those targets from new city worklist */ if (!can_city_build_later(editor->pcity, &pworklist->entries[count])) { continue; @@ -695,20 +696,20 @@ static void add_global_worklist(struct widget *pwidget) worklist_append(&editor->worklist_copy, &pworklist->entries[count]); - /* create widget */ + /* Create widget */ if (VUT_UTYPE == pworklist->entries[count].kind) { buf = 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)); buf->id = MAX_ID - cid_encode_unit(pworklist->entries[count].value.utype); } else { buf = create_iconlabel(NULL, pwidget->dst, - create_utf8_from_char( + create_utf8_from_char_fonto( city_improvement_name_translation(editor->pcity, pworklist->entries[count].value.building), - adj_font(10)), + FONTO_DEFAULT), (WF_RESTORE_BACKGROUND|WF_FREE_DATA)); buf->id = MAX_ID - cid_encode_building(pworklist->entries[count].value.building); } @@ -793,25 +794,25 @@ static void set_global_worklist(struct widget *pwidget) worklist_copy(&editor->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(&editor->worklist_copy, &target, count)) { break; } if (VUT_UTYPE == target.kind) { buf = create_iconlabel(NULL, pwidget->dst, - create_utf8_from_char(utype_name_translation(target.value.utype), - adj_font(10)), - (WF_RESTORE_BACKGROUND|WF_FREE_DATA)); + create_utf8_from_char_fonto(utype_name_translation(target.value.utype), + FONTO_DEFAULT), + (WF_RESTORE_BACKGROUND|WF_FREE_DATA)); buf->id = MAX_ID - B_LAST - utype_number(target.value.utype); } else { buf = create_iconlabel(NULL, pwidget->dst, - create_utf8_from_char(city_improvement_name_translation(editor->pcity, + create_utf8_from_char_fonto(city_improvement_name_translation(editor->pcity, target.value.building), - adj_font(10)), - (WF_RESTORE_BACKGROUND|WF_FREE_DATA)); + FONTO_DEFAULT), + (WF_RESTORE_BACKGROUND|WF_FREE_DATA)); buf->id = MAX_ID - improvement_number(target.value.building); } buf->string_utf8->style |= SF_CENTER; @@ -1131,14 +1132,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}; buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND); editor->worklist_counter = buf; add_to_gui_list(ID_LABEL, buf); /* --------------------------- */ - /* create production progress label or rename worklist edit */ + /* Create production progress label or rename worklist edit */ if (pcity) { /* count == cost */ /* turns == progress */ @@ -1167,7 +1168,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; buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -1192,9 +1193,9 @@ void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl) editor->production_progress = buf; add_to_gui_list(ID_LABEL, buf); } else { - buf = create_edit_from_chars(NULL, pwindow->dst, - global_worklist_name(gwl), adj_font(10), - adj_size(120), WF_RESTORE_BACKGROUND); + buf = create_edit_from_chars_fonto(NULL, pwindow->dst, + global_worklist_name(gwl), FONTO_DEFAULT, + adj_size(120), WF_RESTORE_BACKGROUND); buf->action = rename_worklist_editor_callback; set_wstate(buf, FC_WS_NORMAL); @@ -1245,8 +1246,9 @@ void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl) #endif /* 0 */ if (pcity) { - /* Production Widget Label */ - pstr = create_utf8_from_char(city_production_name_translation(pcity), adj_font(10)); + /* Production Widget Label */ + pstr = create_utf8_from_char_fonto(city_production_name_translation(pcity), + FONTO_DEFAULT); turns = city_production_build_shield_cost(pcity); pstr->style |= SF_CENTER; buf = create_iconlabel(NULL, pwindow->dst, pstr, WF_RESTORE_BACKGROUND); @@ -1266,18 +1268,18 @@ void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl) last = buf; editor->dock = buf; - /* create Widget Labels of worklist entries */ + /* Create Widget Labels of worklist entries */ count = 0; worklist_iterate(&editor->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; buf = create_iconlabel(NULL, pwindow->dst, pstr, @@ -1339,15 +1341,15 @@ void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl) last = editor->work->begin_widget_list; /* --------------------------- */ - /* global worklists */ + /* Global worklists */ if (pcity) { count = 0; global_worklists_iterate(iter_gwl) { - buf = create_iconlabel_from_chars(NULL, pwindow->dst, - global_worklist_name(iter_gwl), - adj_font(10), - WF_RESTORE_BACKGROUND); + buf = create_iconlabel_from_chars_fonto(NULL, pwindow->dst, + global_worklist_name(iter_gwl), + FONTO_DEFAULT, + WF_RESTORE_BACKGROUND); set_wstate(buf, FC_WS_NORMAL); add_to_gui_list(MAX_ID - global_worklist_id(iter_gwl), buf); buf->string_utf8->style |= SF_CENTER; @@ -1389,7 +1391,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 10d0750919..cbb71cfa8a 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