[pango/visible-things: 46/52] fc: Implement showing ignorables
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/visible-things: 46/52] fc: Implement showing ignorables
- Date: Sat, 13 Jul 2019 03:33:23 +0000 (UTC)
commit 8ece17ded5a08c9593678f7956f272253eee59bc
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jul 7 14:11:56 2019 -0400
fc: Implement showing ignorables
We tell harfbuzz to preserve the ignorables in
shaping output, and use our glyph lookup to turn
them into unknown glyphs that we can shape into
custom hex boxes.
pango/pangofc-shape.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
---
diff --git a/pango/pangofc-shape.c b/pango/pangofc-shape.c
index 15ddea5b..991b7612 100644
--- a/pango/pangofc-shape.c
+++ b/pango/pangofc-shape.c
@@ -129,6 +129,15 @@ pango_hb_font_get_nominal_glyph (hb_font_t *font,
{
PangoHbShapeContext *context = (PangoHbShapeContext *) font_data;
+ if (context->flags & PANGO_SHAPE_SHOW_IGNORABLES)
+ {
+ if (pango_get_ignorable (unicode))
+ {
+ *glyph = PANGO_GET_UNKNOWN_GLYPH (unicode);
+ return TRUE;
+ }
+ }
+
if (hb_font_get_glyph (context->parent, unicode, 0, glyph))
return TRUE;
@@ -181,6 +190,14 @@ pango_hb_font_get_glyph_advance (hb_font_t *font,
{
PangoHbShapeContext *context = (PangoHbShapeContext *) font_data;
+ if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+ {
+ PangoRectangle logical;
+
+ pango_font_get_glyph_extents (context->font, glyph, NULL, &logical);
+ return logical.width;
+ }
+
return hb_font_get_glyph_h_advance (context->parent, glyph);
}
@@ -193,6 +210,20 @@ pango_hb_font_get_glyph_extents (hb_font_t *font,
{
PangoHbShapeContext *context = (PangoHbShapeContext *) font_data;
+ if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+ {
+ PangoRectangle ink;
+
+ pango_font_get_glyph_extents (context->font, glyph, &ink, NULL);
+
+ extents->x_bearing = ink.x;
+ extents->y_bearing = ink.y;
+ extents->width = ink.width;
+ extents->height = ink.height;
+
+ return TRUE;
+ }
+
return hb_font_get_glyph_extents (context->parent, glyph, extents);
}
@@ -283,6 +314,7 @@ pango_hb_shape (const char *item_text,
PangoHbShapeContext context;
hb_font_t *hb_font;
hb_buffer_t *hb_buffer;
+ hb_buffer_flags_t hb_buffer_flags;
hb_direction_t hb_direction;
gboolean free_buffer;
hb_glyph_info_t *hb_glyph;
@@ -306,6 +338,11 @@ pango_hb_shape (const char *item_text,
if (PANGO_GRAVITY_IS_IMPROPER (analysis->gravity))
hb_direction = HB_DIRECTION_REVERSE (hb_direction);
+ hb_buffer_flags = HB_BUFFER_FLAG_BOT | HB_BUFFER_FLAG_EOT;
+
+ if (flags & PANGO_SHAPE_SHOW_IGNORABLES)
+ hb_buffer_flags |= HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES;
+
/* setup buffer */
hb_buffer_set_direction (hb_buffer, hb_direction);
@@ -314,7 +351,7 @@ pango_hb_shape (const char *item_text,
#if HB_VERSION_ATLEAST(1,0,3)
hb_buffer_set_cluster_level (hb_buffer, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
#endif
- hb_buffer_set_flags (hb_buffer, HB_BUFFER_FLAG_BOT | HB_BUFFER_FLAG_EOT);
+ hb_buffer_set_flags (hb_buffer, hb_buffer_flags);
hb_buffer_add_utf8 (hb_buffer, paragraph_text, paragraph_length, item_offset, item_length);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]