[pango/more-log-attr-things: 3/8] layout: Don't overwrite eot attrs




commit 5b00cbc5c95666e392913306fb706490bda026be
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Aug 24 00:43:53 2021 -0400

    layout: Don't overwrite eot attrs
    
    Don't overwrite the mandatory break at eot,
    and enforce no break at sot.

 pango/pango-layout.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 6b14a5dd..bf4a166f 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -4224,9 +4224,17 @@ get_items_log_attrs (const char    *text,
 {
   int offset = 0;
   GList *l;
+  PangoLogAttr attr_before = log_attrs[0];
 
   pango_default_break (text + start, length, NULL, log_attrs, log_attrs_len);
 
+  if (start > 0)
+    {
+      log_attrs->is_line_break      |= attr_before.is_line_break;
+      log_attrs->is_mandatory_break |= attr_before.is_mandatory_break;
+      log_attrs->is_cursor_position |= attr_before.is_cursor_position;
+    }
+
   for (l = items; l; l = l->next)
     {
       PangoItem *item = l->data;
@@ -4248,6 +4256,15 @@ get_items_log_attrs (const char    *text,
       PangoItem *item = items->data;
       pango_attr_break (text + start, length, attrs, item->offset, log_attrs, log_attrs_len);
     }
+
+  if (start == 0)
+    {
+      log_attrs[0].is_line_break = FALSE;
+      log_attrs[0].is_mandatory_break = FALSE;
+    }
+
+  log_attrs[log_attrs_len - 1].is_line_break = TRUE;
+  log_attrs[log_attrs_len - 1].is_mandatory_break = TRUE;
 }
 
 static PangoAttrList *


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