summaryrefslogtreecommitdiff
path: root/pango/pangofc-shape.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-07-15 20:58:13 -0400
committerMatthias Clasen <mclasen@redhat.com>2019-07-20 11:53:00 -0700
commit1074fcae667461fda72fc85551f37a6fe7eb40ac (patch)
tree67442ab8ace7395f02b92de4f8ae0a514d8d2841 /pango/pangofc-shape.c
parent5c5c7bb310d886c1c4900440aefda78d676c691b (diff)
downloadpango-1074fcae667461fda72fc85551f37a6fe7eb40ac.tar.gz
Don't insert extra runs for hyphens
Instead, reshape the pre-break run with the soft hyphen replaced by an actual hyphen. This is unfortunately inefficient, we copy the entire text for this. The alternative (scatter-gather populating the harfbuzz buffer) is too hard to manage.
Diffstat (limited to 'pango/pangofc-shape.c')
-rw-r--r--pango/pangofc-shape.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/pango/pangofc-shape.c b/pango/pangofc-shape.c
index 910ff4d7..12ce7ddb 100644
--- a/pango/pangofc-shape.c
+++ b/pango/pangofc-shape.c
@@ -158,6 +158,20 @@ pango_hb_shape (PangoFont *font,
hb_buffer_set_flags (hb_buffer, HB_BUFFER_FLAG_BOT | HB_BUFFER_FLAG_EOT);
hb_buffer_add_utf8 (hb_buffer, paragraph_text, paragraph_length, item_offset, item_length);
+ if (analysis->flags & PANGO_ANALYSIS_FLAG_NEED_HYPHEN)
+ {
+ /* Insert either a Unicode or ASCII hyphen. We may
+ * want to look for script-specific hyphens here.
+ */
+ const char *p = paragraph_text + item_offset + item_length;
+ int last_char_len = p - g_utf8_prev_char (p);
+ hb_codepoint_t glyph;
+
+ if (hb_font_get_nominal_glyph (hb_font, 0x2010, &glyph))
+ hb_buffer_add (hb_buffer, 0x2010, item_length - last_char_len);
+ else if (hb_font_get_nominal_glyph (hb_font, '-', &glyph))
+ hb_buffer_add (hb_buffer, '-', item_length - last_char_len);
+ }
pango_font_get_features (font, features, G_N_ELEMENTS (features), &num_features);
apply_extra_attributes (analysis->extra_attrs, features, G_N_ELEMENTS (features), &num_features);