diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c index 87d30c6b..a7e669a3 100644 --- a/src/fe-gtk/setup.c +++ b/src/fe-gtk/setup.c @@ -2349,9 +2349,10 @@ static void setup_apply (struct zoitechatprefs *pr) { #ifdef WIN32 - PangoFontDescription *old_desc; - PangoFontDescription *new_desc; - char buffer[4 * FONTNAMELEN + 1]; + PangoFontDescription *font_desc; + const char *family; + char *families; + char *font_name; #endif int noapply = FALSE; ThemeChangedEvent event; @@ -2430,24 +2431,26 @@ setup_apply (struct zoitechatprefs *pr) memcpy (&prefs, pr, sizeof (prefs)); - event = theme_manager_on_preferences_changed (&old_prefs, &prefs, old_dark_mode, &color_change); - #ifdef WIN32 - /* merge hex_font_main and hex_font_alternative into hex_font_normal */ - old_desc = pango_font_description_from_string (prefs.hex_text_font_main); - sprintf (buffer, "%s,%s", pango_font_description_get_family (old_desc), prefs.hex_text_font_alternative); - new_desc = pango_font_description_from_string (buffer); - pango_font_description_set_weight (new_desc, pango_font_description_get_weight (old_desc)); - pango_font_description_set_style (new_desc, pango_font_description_get_style (old_desc)); - pango_font_description_set_size (new_desc, pango_font_description_get_size (old_desc)); - sprintf (prefs.hex_text_font, "%s", pango_font_description_to_string (new_desc)); - - /* FIXME this is not required after pango_font_description_from_string() - g_free (old_desc); - g_free (new_desc); - */ + /* Append fallback families without losing the selected face attributes. */ + font_desc = pango_font_description_from_string (prefs.hex_text_font_main); + family = pango_font_description_get_family (font_desc); + if (prefs.hex_text_font_alternative[0]) + { + families = family && *family + ? g_strconcat (family, ",", prefs.hex_text_font_alternative, NULL) + : g_strdup (prefs.hex_text_font_alternative); + pango_font_description_set_family (font_desc, families); + g_free (families); + } + font_name = pango_font_description_to_string (font_desc); + g_strlcpy (prefs.hex_text_font, font_name, sizeof prefs.hex_text_font); + g_free (font_name); + pango_font_description_free (font_desc); #endif + event = theme_manager_on_preferences_changed (&old_prefs, &prefs, old_dark_mode, &color_change); + if (prefs.hex_irc_real_name[0] == 0) { fe_message (_("The Real name option cannot be left blank. Falling back to \"realname\"."), FE_MSG_WARN);