fontsel: keep the style when switching family

This commit is contained in:
Daemonratte 2026-10-17 11:14:25 +02:00
commit cf19f77699

View file

@ -1057,25 +1057,15 @@ gtk_font_selection_show_available_styles (GtkFontSelection *fontsel)
g_free (faces);
}
/* This selects a style when the user selects a font. It just uses the first
available style at present. I was thinking of trying to maintain the
selected style, e.g. bold italic, when the user selects different fonts.
However, the interface is so easy to use now I'm not sure it's worth it.
/* This is called when the user selects a font. The style stays what it
was if the new family has it (see gtk_font_selection_show_available_styles()),
so bold stays bold while going through the families.
Note: This will load a font. */
static void
gtk_font_selection_select_best_style (GtkFontSelection *fontsel,
gboolean use_first)
{
GtkTreeIter iter;
GtkTreeModel *model;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (fontsel->face_list));
if (gtk_tree_model_get_iter_first (model, &iter))
{
set_cursor_to_iter (GTK_TREE_VIEW (fontsel->face_list), &iter);
scroll_to_selection (GTK_TREE_VIEW (fontsel->face_list));
}
scroll_to_selection (GTK_TREE_VIEW (fontsel->face_list));
gtk_font_selection_show_available_sizes (fontsel, FALSE);
gtk_font_selection_select_best_size (fontsel);