pidgin: 87a4fd64: Fix apply_font to use a PangoFontDescrip...
deryni at pidgin.im
deryni at pidgin.im
Tue Sep 8 08:52:24 EDT 2009
-----------------------------------------------------------------
Revision: 87a4fd64ae4d373b40df38d1bf8517efb09fdeb6
Ancestor: 48e7bc40f3e696487c1f162edd2f5aeda98dbdd6
Author: deryni at pidgin.im
Date: 2009-08-15T05:45:58
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/87a4fd64ae4d373b40df38d1bf8517efb09fdeb6
Modified files:
pidgin/gtkimhtmltoolbar.c
ChangeLog:
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
-------------- next part --------------
============================================================
--- pidgin/gtkimhtmltoolbar.c 53e32eb99f52d5e1780f762e3abd41db02a38b80
+++ pidgin/gtkimhtmltoolbar.c a33115107d2e568f64b7058604a0db5798a751ce
@@ -133,23 +133,31 @@ cancel_toolbar_font(GtkWidget *widget, G
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);
}
More information about the Commits
mailing list