diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index e934bdf..a154386 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -2044,35 +2044,90 @@ draw_nbsp_at_iter (cairo_t      *cr,
 	cairo_restore (cr);
 }
 
+static gboolean
+check_location (GtkSourceView *view,
+                GtkTextIter   *iter,
+                GtkTextIter   *leading,
+                GtkTextIter   *trailing,
+                gint           leading_flag,
+                gint           text_flag,
+                gint           trailing_flag)
+{
+	gint flags = 0;
+	gint location = view->priv->draw_spaces & (leading_flag |
+	                                           text_flag |
+	                                           trailing_flag);
+
+	/* Draw all by default */
+	if (!location)
+	{
+		return TRUE;
+	}
+
+	if (gtk_text_iter_compare (iter, trailing) >= 0)
+	{
+		flags |= trailing_flag;
+	}
+
+	if (gtk_text_iter_compare (iter, leading) < 0)
+	{
+		flags |= leading_flag;
+	}
+
+	if (flags == 0)
+	{
+		/* Neither leading nor trailing, must be in text */
+		return location & text_flag;
+	}
+	else
+	{
+		return location & flags;
+	}
+}
+
 static void
 draw_spaces_at_iter (cairo_t       *cr,
-		     GtkSourceView *view,
-		     GtkTextIter   *iter,
-		     GdkRectangle   rect)
+                     GtkSourceView *view,
+                     GtkTextIter   *iter,
+                     GtkTextIter   *leading,
+                     GtkTextIter   *trailing,
+                     GdkRectangle   rect)
 {
 	gunichar c;
 
 	c = gtk_text_iter_get_char (iter);
 
 	if (view->priv->draw_spaces & GTK_SOURCE_DRAW_SPACES_TAB &&
-	    c == '\t')
+	    c == '\t' && check_location(view, iter, leading, trailing,
+	                                GTK_SOURCE_DRAW_SPACES_TAB_LEADING,
+	                                GTK_SOURCE_DRAW_SPACES_TAB_TEXT,
+	                                GTK_SOURCE_DRAW_SPACES_TAB_TRAILING))
 	{
 		draw_tab_at_iter (cr, GTK_TEXT_VIEW (view), iter, rect);
 	}
 	else if (view->priv->draw_spaces & GTK_SOURCE_DRAW_SPACES_NBSP &&
-		 g_unichar_break_type (c) == G_UNICODE_BREAK_NON_BREAKING_GLUE)
+	         g_unichar_break_type (c) == G_UNICODE_BREAK_NON_BREAKING_GLUE &&
+	         check_location(view, iter, leading, trailing,
+	                        GTK_SOURCE_DRAW_SPACES_NBSP_LEADING,
+	                        GTK_SOURCE_DRAW_SPACES_NBSP_TEXT,
+	                        GTK_SOURCE_DRAW_SPACES_NBSP_TRAILING))
 	{
 		/* We also need to check if we want to draw a narrowed space */
 		draw_nbsp_at_iter (cr, GTK_TEXT_VIEW (view), iter, rect,
 		                   c == 0x202F);
 	}
 	else if (view->priv->draw_spaces & GTK_SOURCE_DRAW_SPACES_SPACE &&
-	         g_unichar_type (c) == G_UNICODE_SPACE_SEPARATOR)
+	         g_unichar_type (c) == G_UNICODE_SPACE_SEPARATOR &&
+	         g_unichar_break_type (c) != G_UNICODE_BREAK_NON_BREAKING_GLUE &&
+	         check_location(view, iter, leading, trailing,
+	                        GTK_SOURCE_DRAW_SPACES_SPACE_LEADING,
+	                        GTK_SOURCE_DRAW_SPACES_SPACE_TEXT,
+	                        GTK_SOURCE_DRAW_SPACES_SPACE_TRAILING))
 	{
 		draw_space_at_iter (cr, GTK_TEXT_VIEW (view), iter, rect);
 	}
 	else if (view->priv->draw_spaces & GTK_SOURCE_DRAW_SPACES_NEWLINE &&
-		 gtk_text_iter_ends_line (iter) && !gtk_text_iter_is_end (iter))
+	         gtk_text_iter_ends_line (iter) && !gtk_text_iter_is_end (iter))
 	{
 		draw_newline_at_iter (cr, GTK_TEXT_VIEW (view), iter, rect);
 	}
@@ -2122,44 +2177,6 @@ get_leading_trailing (GtkTextIter *iter,
 	}
 }
 
-static gboolean
-check_location (GtkSourceView *view,
-                GtkTextIter   *iter,
-                GtkTextIter   *leading,
-                GtkTextIter   *trailing)
-{
-	gint flags = 0;
-	gint location = view->priv->draw_spaces & (GTK_SOURCE_DRAW_SPACES_LEADING |
-	                                           GTK_SOURCE_DRAW_SPACES_TEXT |
-	                                           GTK_SOURCE_DRAW_SPACES_TRAILING);
-
-	/* Draw all by default */
-	if (!location)
-	{
-		return TRUE;
-	}
-
-	if (gtk_text_iter_compare (iter, trailing) >= 0)
-	{
-		flags |= GTK_SOURCE_DRAW_SPACES_TRAILING;
-	}
-
-	if (gtk_text_iter_compare (iter, leading) < 0)
-	{
-		flags |= GTK_SOURCE_DRAW_SPACES_LEADING;
-	}
-
-	if (flags == 0)
-	{
-		/* Neither leading nor trailing, must be in text */
-		return location & GTK_SOURCE_DRAW_SPACES_TEXT;
-	}
-	else
-	{
-		return location & flags;
-	}
-}
-
 static void
 draw_tabs_and_spaces (GtkSourceView *view,
 		      cairo_t       *cr)
@@ -2242,9 +2259,12 @@ draw_tabs_and_spaces (GtkSourceView *view,
 			continue;
 		}
 
-		if (check_location (view, &s, &leading, &trailing))
+		if (check_location(view, &s, &leading, &trailing,
+		                   GTK_SOURCE_DRAW_SPACES_LEADING,
+		                   GTK_SOURCE_DRAW_SPACES_TEXT,
+		                   GTK_SOURCE_DRAW_SPACES_TRAILING))
 		{
-			draw_spaces_at_iter (cr, view, &s, rect);
+			draw_spaces_at_iter (cr, view, &s, &leading, &trailing, rect);
 		}
 
 		if (!gtk_text_iter_forward_char (&s))
diff --git a/gtksourceview/gtksourceview.h b/gtksourceview/gtksourceview.h
index 205323b..a916c93 100644
--- a/gtksourceview/gtksourceview.h
+++ b/gtksourceview/gtksourceview.h
@@ -106,36 +106,58 @@ typedef enum
 
 /**
  * GtkSourceDrawSpacesFlags:
- * @GTK_SOURCE_DRAW_SPACES_SPACE: whether the space character should be drawn.
- * @GTK_SOURCE_DRAW_SPACES_TAB: whether the tab character should be drawn.
- * @GTK_SOURCE_DRAW_SPACES_NEWLINE: whether the line breaks should be drawn.
- * @GTK_SOURCE_DRAW_SPACES_NBSP: whether the non-breaking whitespaces should be drawn.
- * @GTK_SOURCE_DRAW_SPACES_LEADING: whether leading whitespaces should be drawn.
- * @GTK_SOURCE_DRAW_SPACES_TEXT: whether whitespaces inside text should be drawn.
- * @GTK_SOURCE_DRAW_SPACES_TRAILING: whether trailing whitespaces should be drawn.
- * @GTK_SOURCE_DRAW_SPACES_ALL: wheter all kind of spaces should be drawn.
+ * @GTK_SOURCE_DRAW_SPACES_SPACE: Whether the space character should be drawn.
+ * @GTK_SOURCE_DRAW_SPACES_TAB: Whether the tab character should be drawn.
+ * @GTK_SOURCE_DRAW_SPACES_NEWLINE: Whether the line breaks should be drawn.
+ * @GTK_SOURCE_DRAW_SPACES_NBSP: Whether the non-breaking whitespaces should be drawn.
+ * @GTK_SOURCE_DRAW_SPACES_LEADING: Whether leading whitespaces should be drawn. Affects all types of whitespace.
+ * @GTK_SOURCE_DRAW_SPACES_TEXT: Whether whitespaces inside text should be drawn. Affects all types of whitespace.
+ * @GTK_SOURCE_DRAW_SPACES_TRAILING: Whether trailing whitespaces should be drawn. Affects all types of whitespace.
+ * @GTK_SOURCE_DRAW_SPACES_SPACES_LEADING: Whether leading spaces should be drawn.
+ * @GTK_SOURCE_DRAW_SPACES_SPACES_TEXT: Whether spaces inside text should be drawn.
+ * @GTK_SOURCE_DRAW_SPACES_SPACES_TRAILING: Whether trailing spaces should be drawn.
+ * @GTK_SOURCE_DRAW_SPACES_TABS_LEADING: Whether leading tabs should be drawn.
+ * @GTK_SOURCE_DRAW_SPACES_TABS_TEXT: Whether tabs inside text should be drawn.
+ * @GTK_SOURCE_DRAW_SPACES_TABS_TRAILING: Whether trailing tabs should be drawn.
+ * @GTK_SOURCE_DRAW_SPACES_NBSP_LEADING: Whether leading non-breaking spaces should be drawn.
+ * @GTK_SOURCE_DRAW_SPACES_NBSP_TEXT: Whether non-breaking spaces inside text should be drawn.
+ * @GTK_SOURCE_DRAW_SPACES_NBSP_TRAILING: Whether trailing non-breaking spaces should be drawn.
+ * @GTK_SOURCE_DRAW_SPACES_ALL: Wheter all kind of spaces should be drawn.
  *
  * GtkSourceDrawSpacesFlags determine what kind of spaces whould be drawn. If none
  * of GTK_SOURCE_DRAW_SPACES_LEADING, GTK_SOURCE_DRAW_SPACES_TEXT or
  * GTK_SOURCE_DRAW_SPACES_TRAILING is specified, whitespaces at any position in
  * the line will be drawn (i.e. it has the same effect as specifying all of them).
+ * The same goes for flags controlling visibility of individual types of spaces,
+ * for example, if GTK_SOURCE_DRAW_SPACES_LEADING is specified, but none of
+ * GTK_SOURCE_DRAW_SPACES_SPACES_LEADING, GTK_SOURCE_DRAW_SPACES_SPACES_TEXT or
+ * GTK_SOURCE_DRAW_SPACES_SPACES_TRAILING are, leading spaces are drawn.
  */
 typedef enum
 {
-	GTK_SOURCE_DRAW_SPACES_SPACE      = 1 << 0,
-	GTK_SOURCE_DRAW_SPACES_TAB        = 1 << 1,
-	GTK_SOURCE_DRAW_SPACES_NEWLINE    = 1 << 2,
-	GTK_SOURCE_DRAW_SPACES_NBSP       = 1 << 3,
-	GTK_SOURCE_DRAW_SPACES_LEADING    = 1 << 4,
-	GTK_SOURCE_DRAW_SPACES_TEXT       = 1 << 5,
-	GTK_SOURCE_DRAW_SPACES_TRAILING   = 1 << 6,
-	GTK_SOURCE_DRAW_SPACES_ALL        = (GTK_SOURCE_DRAW_SPACES_SPACE   | \
-	                                     GTK_SOURCE_DRAW_SPACES_TAB     | \
-	                                     GTK_SOURCE_DRAW_SPACES_NEWLINE | \
-	                                     GTK_SOURCE_DRAW_SPACES_NBSP | \
-	                                     GTK_SOURCE_DRAW_SPACES_LEADING | \
-	                                     GTK_SOURCE_DRAW_SPACES_TEXT | \
-	                                     GTK_SOURCE_DRAW_SPACES_TRAILING)
+	GTK_SOURCE_DRAW_SPACES_SPACE          = 1 << 0,
+	GTK_SOURCE_DRAW_SPACES_TAB            = 1 << 1,
+	GTK_SOURCE_DRAW_SPACES_NEWLINE        = 1 << 2,
+	GTK_SOURCE_DRAW_SPACES_NBSP           = 1 << 3,
+	GTK_SOURCE_DRAW_SPACES_LEADING        = 1 << 4,
+	GTK_SOURCE_DRAW_SPACES_TEXT           = 1 << 5,
+	GTK_SOURCE_DRAW_SPACES_TRAILING       = 1 << 6,
+	GTK_SOURCE_DRAW_SPACES_SPACE_LEADING  = 1 << 7,
+	GTK_SOURCE_DRAW_SPACES_SPACE_TEXT     = 1 << 8,
+	GTK_SOURCE_DRAW_SPACES_SPACE_TRAILING = 1 << 9,
+	GTK_SOURCE_DRAW_SPACES_TAB_LEADING    = 1 << 10,
+	GTK_SOURCE_DRAW_SPACES_TAB_TEXT       = 1 << 11,
+	GTK_SOURCE_DRAW_SPACES_TAB_TRAILING   = 1 << 12,
+	GTK_SOURCE_DRAW_SPACES_NBSP_LEADING   = 1 << 13,
+	GTK_SOURCE_DRAW_SPACES_NBSP_TEXT      = 1 << 14,
+	GTK_SOURCE_DRAW_SPACES_NBSP_TRAILING  = 1 << 15,
+	GTK_SOURCE_DRAW_SPACES_ALL            = (GTK_SOURCE_DRAW_SPACES_SPACE   | \
+	                                         GTK_SOURCE_DRAW_SPACES_TAB     | \
+	                                         GTK_SOURCE_DRAW_SPACES_NEWLINE | \
+	                                         GTK_SOURCE_DRAW_SPACES_NBSP    | \
+	                                         GTK_SOURCE_DRAW_SPACES_LEADING | \
+	                                         GTK_SOURCE_DRAW_SPACES_TEXT    | \
+	                                         GTK_SOURCE_DRAW_SPACES_TRAILING)
 } GtkSourceDrawSpacesFlags;
 
 
