[pango/visible-things: 33/37] fc: Implement showing space



commit 00885c90297d73764521e2e70c5f591d938bba28
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jul 10 09:02:54 2019 -0400

    fc: Implement showing space
    
    When told to make space visible, we use the glyph
    for 0x2324 instead of 0x20. We have to do some
    post-processing to counteract harfbuzz using
    space glyphs for its own purposes.

 pango/pangofc-shape.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/pango/pangofc-shape.c b/pango/pangofc-shape.c
index 3e9502ff..17c67907 100644
--- a/pango/pangofc-shape.c
+++ b/pango/pangofc-shape.c
@@ -97,6 +97,21 @@ pango_fc_hb_font_get_nominal_glyph (hb_font_t *font, void *font_data,
         }
     }
 
+  if (context->shape_flags & PANGO_SHAPE_SHOW_SPACE)
+    {
+      if (g_unichar_type (unicode) == G_UNICODE_SPACE_SEPARATOR)
+        {
+          /* Replace 0x20 by visible space, since we
+           * don't draw a hex box for 0x20
+           */
+          if (unicode == 0x20)
+            *glyph = PANGO_GET_UNKNOWN_GLYPH (0x2423);
+          else
+            *glyph = PANGO_GET_UNKNOWN_GLYPH (unicode);
+          return TRUE;
+        }
+    }
+
   *glyph = pango_fc_font_get_glyph (fc_font, unicode);
   if (G_LIKELY (*glyph))
     return TRUE;
@@ -437,6 +452,7 @@ _pango_fc_shape (PangoFont           *font,
   hb_buffer_set_cluster_level (hb_buffer, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
 #endif
   hb_buffer_set_flags (hb_buffer, hb_buffer_flags);
+  hb_buffer_set_invisible_glyph (hb_buffer, PANGO_GLYPH_EMPTY);
 
   hb_buffer_add_utf8 (hb_buffer, paragraph_text, paragraph_length, item_offset, item_length);
 
@@ -504,6 +520,7 @@ _pango_fc_shape (PangoFont           *font,
   pango_glyph_string_set_size (glyphs, num_glyphs);
   infos = glyphs->glyphs;
   last_cluster = -1;
+
   for (i = 0; i < num_glyphs; i++)
     {
       infos[i].glyph = hb_glyph->codepoint;


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