summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-07-07 16:44:35 -0400
committerMatthias Clasen <mclasen@redhat.com>2019-07-25 00:43:52 -0400
commitf0f37ad13596d1e9b25a8a1cca202ea1ce404f6d (patch)
treefc43678399915ef7c00dffe6d4ff54725959b986
parent283c2d998b8efc2901dafaf9ed233782cc612214 (diff)
downloadpango-f0f37ad13596d1e9b25a8a1cca202ea1ce404f6d.tar.gz
layout: Make tab visible too
When the 'show space' attribute is present, arrange for tab characters to be passed on to the rendering layer as non-empty.
-rw-r--r--pango/pango-layout.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index b3303b3d..d4b78795 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)