# HG changeset patch # User Etan Reisner # Date 1250315158 0 # Node ID 401012968feacca9e8b798b81a4961480ed8b924 # Parent 329d665c78b2e0af842335bb3fb9c058bde7597a Fix apply_font to use a PangoFontDescription to get the requested font family name rather than just stripping any trailing digits from the full font string. This seemed to do the right thing for me for all fonts I tried, but it would be good if people who actually use custom fonts would give this a whirl. Fixes #5030 diff -r 329d665c78b2 -r 401012968fea pidgin/gtkimhtmltoolbar.c --- a/pidgin/gtkimhtmltoolbar.c Sat Aug 15 05:11:36 2009 +0000 +++ b/pidgin/gtkimhtmltoolbar.c Sat Aug 15 05:45:58 2009 +0000 @@ -133,22 +133,30 @@ destroy_toolbar_font(widget, NULL, toolbar); } -static void apply_font(GtkWidget *widget, GtkFontSelection *fontsel) +static void +apply_font(GtkWidget *widget, GtkFontSelectionDialog *fontsel) { /* this could be expanded to include font size, weight, etc. but for now only works with font face */ - char *fontname; - char *space; - GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(fontsel), "purple_toolbar"); + gchar *fontname = gtk_font_selection_dialog_get_font_name(fontsel); + GtkIMHtmlToolbar *toolbar = g_object_get_data(G_OBJECT(fontsel), + "purple_toolbar"); - fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel)); + if (fontname) { + const gchar *family_name = NULL; + PangoFontDescription *desc = NULL; - space = strrchr(fontname, ' '); - if(space && isdigit(*(space+1))) - *space = '\0'; + desc = pango_font_description_from_string(fontname); + family_name = pango_font_description_get_family(desc); - gtk_imhtml_toggle_fontface(GTK_IMHTML(toolbar->imhtml), fontname); - g_free(fontname); + if (family_name) { + gtk_imhtml_toggle_fontface(GTK_IMHTML(toolbar->imhtml), + family_name); + } + + pango_font_description_free(desc); + g_free(fontname); + } cancel_toolbar_font(NULL, toolbar); }