]> git.sur5r.net Git - glabels/commitdiff
Adds test to ensure a valid font family.
authorJim Evins <evins@snaught.com>
Wed, 25 Dec 2002 03:02:00 +0000 (03:02 +0000)
committerJim Evins <evins@snaught.com>
Wed, 25 Dec 2002 03:02:00 +0000 (03:02 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@219 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/src/label-text.c
glabels2/src/wdgt-text-props.c

index 37d010ed3367af1dbca9000b1baa8a82401cddcd..240507d2194fad657035b15911ab4e48aaf8adef 100644 (file)
@@ -231,15 +231,29 @@ gl_label_text_set_props (glLabelText     *ltext,
                         guint            color,
                         GtkJustification just)
 {
-       GdkPixbuf *pixbuf;
+       GList     *family_names;
+       gchar     *good_font_family;
 
        gl_debug (DEBUG_LABEL, "START");
 
        g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext));
 
+       /* Make sure we have a valid font family.  if not privide a good default. */
+       family_names = gnome_font_family_list ();
+       if (g_list_find_custom (family_names, font_family, (GCompareFunc)g_utf8_collate)) {
+               good_font_family = g_strdup (font_family);
+       } else {
+               if (family_names != NULL) {
+                       good_font_family = g_strdup (family_names->data); /* 1st entry */
+               } else {
+                       good_font_family = NULL;
+               }
+       }
+       gnome_font_family_list_free (family_names);
+
        g_free (ltext->private->font_family);
 
-       ltext->private->font_family      = g_strdup (font_family);
+       ltext->private->font_family      = good_font_family;
        ltext->private->font_size        = font_size;
        ltext->private->font_weight      = font_weight;
        ltext->private->font_italic_flag = font_italic_flag;
index 947045854f706de2ba7bb6c691948248761117a3..7a727404fa673dc1a35c87a1208f7f379f42455d 100644 (file)
@@ -409,7 +409,24 @@ gl_wdgt_text_props_set_params (glWdgtTextProps  *text,
                               guint            color,
                               GtkJustification just)
 {
-       gtk_entry_set_text (GTK_ENTRY (text->font_family_entry), font_family);
+       GList *family_names;
+       gchar *good_font_family;
+
+       /* Make sure we have a valid font family.  if not privide a good default. */
+       family_names = gnome_font_family_list ();
+       if (g_list_find_custom (family_names, font_family, (GCompareFunc)g_utf8_collate)) {
+               good_font_family = g_strdup (font_family);
+       } else {
+               if (family_names != NULL) {
+                       good_font_family = g_strdup (family_names->data); /* 1st entry */
+               } else {
+                       good_font_family = NULL;
+               }
+       }
+       gnome_font_family_list_free (family_names);
+
+       gtk_entry_set_text (GTK_ENTRY (text->font_family_entry), good_font_family);
+       g_free (good_font_family);
 
        gtk_spin_button_set_value (GTK_SPIN_BUTTON (text->font_size_spin),
                                   font_size);