[pango/visible-things: 66/71] layout: Make tab visible too



commit 7f808267d903876350f820ef1299362ad007e994
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jul 7 16:44:35 2019 -0400

    layout: Make tab visible too
    
    When the 'visible space' option is set, also
    arrange for tab characters to be passed on to
    the rendering layer as non-empty.

 pango/pango-layout.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index e998a641..06a07afc 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -2975,6 +2975,7 @@ pango_layout_line_leaked (PangoLayoutLine *line)
  *****************/
 
 static void shape_tab (PangoLayoutLine  *line,
+                       PangoItem        *item,
                       PangoGlyphString *glyphs);
 
 static void
@@ -3182,8 +3183,26 @@ line_width (PangoLayoutLine *line)
   return width;
 }
 
+static gboolean
+showing_space (const PangoAnalysis *analysis)
+{
+  GSList *l;
+
+  for (l = analysis->extra_attrs; l; l = l->next)
+    {
+      PangoAttribute *attr = l->data;
+
+      if (attr->klass->type == PANGO_ATTR_SHOW &&
+          (((PangoAttrInt*)attr)->value & PANGO_SHOW_SPACES) != 0)
+        return TRUE;
+    }
+
+  return FALSE;
+}
+
 static void
 shape_tab (PangoLayoutLine  *line,
+           PangoItem        *item,
           PangoGlyphString *glyphs)
 {
   int i, space_width;
@@ -3192,7 +3211,10 @@ shape_tab (PangoLayoutLine  *line,
 
   pango_glyph_string_set_size (glyphs, 1);
 
-  glyphs->glyphs[0].glyph = PANGO_GLYPH_EMPTY;
+  if (showing_space (&item->analysis))
+    glyphs->glyphs[0].glyph = PANGO_GET_UNKNOWN_GLYPH ('\t');
+  else
+    glyphs->glyphs[0].glyph = PANGO_GLYPH_EMPTY;
   glyphs->glyphs[0].geometry.x_offset = 0;
   glyphs->glyphs[0].geometry.y_offset = 0;
   glyphs->glyphs[0].attr.is_cluster_start = 1;
@@ -3329,7 +3351,7 @@ shape_run (PangoLayoutLine *line,
   PangoGlyphString *glyphs = pango_glyph_string_new ();
 
   if (layout->text[item->offset] == '\t')
-    shape_tab (line, glyphs);
+    shape_tab (line, item, glyphs);
   else
     {
       if (state->properties.shape_set)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]