[pango: 6/8] layout: Fix reshaping with hyphen runs



commit d6bc8daa6935b53c15d254e70051ba6b134c759c
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jul 17 14:29:02 2019 -0400

    layout: Fix reshaping with hyphen runs
    
    When we are uninserting a hyphen run, we need
    to undo the modifications of the item we split
    it off from.

 pango/pango-layout.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 9300a76a..7e450f5e 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -2991,7 +2991,8 @@ free_run (PangoLayoutRun *run, gpointer data)
 static PangoItem *
 uninsert_run (PangoLayoutLine *line)
 {
-  PangoLayoutRun *run;
+  PangoLayout *layout = line->layout;
+  PangoLayoutRun *run, *prev;
   PangoItem *item;
 
   GSList *tmp_node = line->runs;
@@ -3002,6 +3003,18 @@ uninsert_run (PangoLayoutLine *line)
   line->runs = tmp_node->next;
   line->length -= item->length;
 
+  if (item->length == 2 &&
+      strncmp (layout->text + run->item->offset, "\302\255", 2) == 0)
+    {
+      /* this is a hyphen run, add the SHY back
+       * to the previous item
+       */
+      prev = line->runs->data;
+      item = prev->item;
+      item->length += 2;
+      item->num_chars += 1;
+    }
+
   g_slist_free_1 (tmp_node);
   free_run (run, (gpointer)FALSE);
 
@@ -3929,7 +3942,7 @@ process_line (PangoLayout    *layout,
        case BREAK_NONE_FIT:
          /* Back up over unused runs to run where there is a break */
          while (line->runs && line->runs != break_link)
-           state->items = g_list_prepend (state->items, uninsert_run (line);
+           state->items = g_list_prepend (state->items, uninsert_run (line));
 
          state->start_offset = break_start_offset;
          state->remaining_width = break_remaining_width;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]