summaryrefslogtreecommitdiff
path: root/gtk/gtkfontchooserwidget.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-09-21 05:44:22 +0200
committerBenjamin Otte <otte@redhat.com>2011-09-22 21:44:05 +0200
commitc9ef2d019e425b76467ad3867eaffa8b51a22726 (patch)
tree7521e1083c5a29280ef2d1922b1028c224accc5e /gtk/gtkfontchooserwidget.c
parent7d5d0a19e75db97f5c071c4a5c4bab4a7a584063 (diff)
downloadgtk+-c9ef2d019e425b76467ad3867eaffa8b51a22726.tar.gz
fontchooser: Only compare font descriptions when families match
This way, we can find fonts way quicker as we only need to create font descriptions for fonts with matching families. Most importantly, we're rather quick in the "the font doesn't exist" case.
Diffstat (limited to 'gtk/gtkfontchooserwidget.c')
-rw-r--r--gtk/gtkfontchooserwidget.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index e3844a963c..346c9a4f03 100644
--- a/gtk/gtkfontchooserwidget.c
+++ b/gtk/gtkfontchooserwidget.c
@@ -875,6 +875,13 @@ gtk_font_chooser_widget_finalize (GObject *object)
}
static gboolean
+my_pango_font_family_equal (const char *familya,
+ const char *familyb)
+{
+ return g_ascii_strcasecmp (familya, familyb) == 0;
+}
+
+static gboolean
gtk_font_chooser_widget_find_font (GtkFontChooserWidget *fontchooser,
const PangoFontDescription *font_desc,
/* out arguments */
@@ -882,12 +889,24 @@ gtk_font_chooser_widget_find_font (GtkFontChooserWidget *fontchooser,
{
GtkFontChooserWidgetPrivate *priv = fontchooser->priv;
PangoFontDescription *desc;
+ PangoFontFamily *family;
gboolean valid;
+ if (pango_font_description_get_family (font_desc) == NULL)
+ return FALSE;
+
for (valid = gtk_tree_model_get_iter_first (priv->model, iter);
valid;
valid = gtk_tree_model_iter_next (priv->model, iter))
{
+ gtk_tree_model_get (priv->model, iter,
+ FAMILY_COLUMN, &family,
+ -1);
+
+ if (!my_pango_font_family_equal (pango_font_description_get_family (font_desc),
+ pango_font_family_get_name (family)))
+ continue;
+
desc = tree_model_get_font_description (priv->model, iter);
pango_font_description_merge_static (desc, font_desc, FALSE);