[pango/visible-things: 12/13] fc: Implement showing space
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/visible-things: 12/13] fc: Implement showing space
- Date: Sun, 7 Jul 2019 18:31:10 +0000 (UTC)
commit ff7deea2263c1310c15a62bb4efdd782cbbf9b3e
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jul 7 14:15:00 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 | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
---
diff --git a/pango/pangofc-shape.c b/pango/pangofc-shape.c
index 3e9502ff..ca2a819a 100644
--- a/pango/pangofc-shape.c
+++ b/pango/pangofc-shape.c
@@ -97,6 +97,16 @@ pango_fc_hb_font_get_nominal_glyph (hb_font_t *font, void *font_data,
}
}
+ if (context->shape_flags & PANGO_SHAPE_SHOW_SPACE)
+ {
+ if (unicode == 0x20)
+ {
+ *glyph = pango_fc_font_get_glyph (fc_font, 0x2423);
+ if (*glyph)
+ return TRUE;
+ }
+ }
+
*glyph = pango_fc_font_get_glyph (fc_font, unicode);
if (G_LIKELY (*glyph))
return TRUE;
@@ -354,6 +364,8 @@ _pango_fc_shape (PangoFont *font,
PangoGlyphInfo *infos;
const char *variations;
PangoShapeFlags shape_flags;
+ PangoGlyph space_glyph;
+ PangoGlyph visible_space_glyph;
g_return_if_fail (font != NULL);
g_return_if_fail (analysis != NULL);
@@ -504,9 +516,29 @@ _pango_fc_shape (PangoFont *font,
pango_glyph_string_set_size (glyphs, num_glyphs);
infos = glyphs->glyphs;
last_cluster = -1;
+
+ if (shape_flags & PANGO_SHAPE_SHOW_SPACE)
+ {
+ space_glyph = pango_fc_font_get_glyph (fc_font, 0x20);
+ visible_space_glyph = pango_fc_font_get_glyph (fc_font, 0x2423);
+ }
+
for (i = 0; i < num_glyphs; i++)
{
infos[i].glyph = hb_glyph->codepoint;
+
+ if (shape_flags & PANGO_SHAPE_SHOW_SPACE)
+ {
+ /* harfbuzz replaces ignorables with space, and
+ * we don't want those to show up as visible space.
+ * So check that the visible space comes from a
+ * space in the input. If it doesn't, turn it back
+ * into regular space.
+ */
+ if (hb_glyph->codepoint == visible_space_glyph &&
+ paragraph_text[hb_glyph->cluster] != ' ')
+ infos[i].glyph = space_glyph;
+ }
glyphs->log_clusters[i] = hb_glyph->cluster - item_offset;
infos[i].attr.is_cluster_start = glyphs->log_clusters[i] != last_cluster;
hb_glyph++;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]