[pango/visible-things: 30/37] fc: Implement showing ignorables
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/visible-things: 30/37] fc: Implement showing ignorables
- Date: Wed, 10 Jul 2019 13:11:51 +0000 (UTC)
commit c44caa6eda078ca38c9ec643ee6d6a3dbb43e158
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 | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/pango/pangofc-shape.c b/pango/pangofc-shape.c
index 12a0f072..3e9502ff 100644
--- a/pango/pangofc-shape.c
+++ b/pango/pangofc-shape.c
@@ -29,6 +29,7 @@
#include "pangofc-private.h"
#include "pangofc-font-private.h"
#include "pangofc-fontmap-private.h"
+#include "pango-impl-utils.h"
#include <hb-ft.h>
#include <hb-glib.h>
@@ -87,6 +88,15 @@ pango_fc_hb_font_get_nominal_glyph (hb_font_t *font, void *font_data,
PangoFcHbContext *context = (PangoFcHbContext *) font_data;
PangoFcFont *fc_font = context->fc_font;
+ if (context->shape_flags & PANGO_SHAPE_SHOW_IGNORABLES)
+ {
+ if (pango_get_ignorable (unicode))
+ {
+ *glyph = PANGO_GET_UNKNOWN_GLYPH (unicode);
+ return TRUE;
+ }
+ }
+
*glyph = pango_fc_font_get_glyph (fc_font, unicode);
if (G_LIKELY (*glyph))
return TRUE;
@@ -330,6 +340,7 @@ _pango_fc_shape (PangoFont *font,
hb_face_t *hb_face;
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;
@@ -412,6 +423,11 @@ _pango_fc_shape (PangoFont *font,
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 (shape_flags & PANGO_SHAPE_SHOW_IGNORABLES)
+ hb_buffer_flags |= HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES;
+
/* setup buffer */
hb_buffer_set_direction (hb_buffer, hb_direction);
@@ -420,7 +436,7 @@ _pango_fc_shape (PangoFont *font,
#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]