[pango/visible-things-2: 10/16] fc: Implement showing ignorables
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/visible-things-2: 10/16] fc: Implement showing ignorables
- Date: Wed, 10 Jul 2019 19:24:34 +0000 (UTC)
commit bb9e441e550366b0283a4a5be3bf8a18d731f533
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 | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
---
diff --git a/pango/pangofc-shape.c b/pango/pangofc-shape.c
index 7ba15ef9..c33a19e1 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>
@@ -86,6 +87,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;
@@ -136,6 +146,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);
}
@@ -148,6 +166,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);
}
@@ -238,6 +270,7 @@ _pango_fc_shape (PangoFont *font,
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;
@@ -261,6 +294,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 (flags & PANGO_SHAPE_SHOW_IGNORABLES)
+ hb_buffer_flags |= HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES;
+
/* setup buffer */
hb_buffer_set_direction (hb_buffer, hb_direction);
@@ -269,7 +307,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]