summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-07-14 21:59:05 -0400
committerMatthias Clasen <mclasen@redhat.com>2019-07-14 22:19:15 -0400
commit2e499aa93b70d14bae605b65755d7c49fa44a61b (patch)
tree41a6ab52d9133cf444c55bad251af2867fcb33e9
parent7e503771d76eb4ad9cc24630e9a37f29f6d6a3be (diff)
downloadpango-2e499aa93b70d14bae605b65755d7c49fa44a61b.tar.gz
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.
-rw-r--r--pango/pango-layout.c9
1 files changed, 8 insertions, 1 deletions
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);