[pango/line-breaking-fixes: 6/12] clear breakpoints flags before breaking




commit f89f4624dc5589bc94aa345e2dd7b9d384d35fad
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Nov 12 11:37:00 2021 -0500

    clear breakpoints flags before breaking

 pango/pango-layout.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index fad92b3b..2e50b6bb 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -3542,9 +3542,11 @@ breakpoint_is_disabled (PangoLayout *layout,
 }
 
 static void
-clear_breakpoint_flags (PangoLayout *layout)
+clear_breakpoint_flags (PangoLayout *layout,
+                        int          start,
+                        int          end)
 {
-  for (int i = 0; i < layout->n_chars + 1; i++)
+  for (int i = start; i < end; i++)
     layout->log_attrs[i].reserved = 0;
 }
 
@@ -3938,6 +3940,8 @@ process_item (PangoLayout     *layout,
           pango_glyph_item_get_logical_widths (&glyph_item, layout->text, state->log_widths);
         }
 
+      clear_breakpoint_flags (layout, state->start_offset, state->start_offset + item->num_chars);
+
     retry_break:
 
       /* See how much of the item we can stuff in the line. */
@@ -4018,7 +4022,7 @@ process_item (PangoLayout     *layout,
 
               break_width = pango_glyph_string_get_width (((PangoGlyphItem *)(line->runs->data))->glyphs);
               if (break_width > state->remaining_width &&
-                  !breakpoint_is_disabled (layout, break_num_chars) &&
+                  !breakpoint_is_disabled (layout, state->start_offset + break_num_chars) &&
                   break_num_chars > 1)
                 {
                   /* Unsplit the item, disable the breakpoint, try again */
@@ -4027,7 +4031,7 @@ process_item (PangoLayout     *layout,
                   pango_item_free (new_item);
                   pango_item_unsplit (item, length, break_num_chars);
 
-                  disable_breakpoint (layout, break_num_chars);
+                  disable_breakpoint (layout, state->start_offset + break_num_chars);
 
                   num_chars = item->num_chars;
                   width = orig_width;
@@ -4644,7 +4648,7 @@ pango_layout_check_lines (PangoLayout *layout)
     }
   while (!done);
 
-  clear_breakpoint_flags (layout);
+  clear_breakpoint_flags (layout, 0, layout->n_chars + 1);
 
   g_free (state.log_widths);
   g_list_free_full (state.baseline_shifts, g_free);


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