[pango] layout: Improve soft hyphen handling
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango] layout: Improve soft hyphen handling
- Date: Mon, 15 Jul 2019 02:21:58 +0000 (UTC)
commit 2e499aa93b70d14bae605b65755d7c49fa44a61b
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jul 14 21:59:05 2019 -0400
layout: Improve soft hyphen handling
Point the item that we create for the inserted hyphen
at the SHY in the paragraph text, shortening the previous
run by one character.
It would be nicer to not insert an extra run at all
and just reshape the previous one in a way that maps
the SHY to a hyphen, but that is more difficult to do
as long as we are going through the shape engine API.
pango/pango-layout.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 411eea5d..37aeed72 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -3432,8 +3432,12 @@ create_hyphen_run (PangoLayout *layout,
run = g_slice_new (PangoGlyphItem);
run->glyphs = pango_glyph_string_new ();
run->item = items->data;
- /* insert after item */
+
+ /* insert after item, use SHY as text */
run->item->offset = item->offset + item->length;
+ run->item->length = 2;
+ run->item->num_chars = 1;
+
g_list_free (items);
pango_shape (hyphen_text, hyphen_len, &run->item->analysis, run->glyphs);
@@ -3507,6 +3511,9 @@ insert_hyphen_after (PangoLayoutLine *line,
PangoLayout *layout = line->layout;
PangoLayoutRun *run;
+ /* Use the SHY as text for the hyphen run */
+ item->num_chars -= 1;
+ item->length -= 2;
run = create_hyphen_run (layout, item);
line->runs = g_slist_prepend (line->runs, run);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]