[pango/avoid-overlong-lines: 1/6] layout: Fix a poblem with hyphen width




commit 36600d89ab3ff847b87daff72e081a5c773a86ef
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Nov 10 17:20:13 2021 -0500

    layout: Fix a poblem with hyphen width
    
    In some cases, we were forgetting to account
    for the width of a hyphen.

 pango/pango-layout.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 9e8ce248..c74e356a 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -3790,9 +3790,10 @@ find_break_extra_width (PangoLayout    *layout,
   return 0;
 }
 
-#if 0
+#if 1
 # define DEBUG debug
-void
+static int pango_layout_line_get_width (PangoLayoutLine *line);
+static void
 debug (const char *where, PangoLayoutLine *line, ParaBreakState *state)
 {
   int line_width = pango_layout_line_get_width (line);
@@ -3919,10 +3920,10 @@ process_item (PangoLayout     *layout,
       extra_width = 0;
       for (num_chars = 0; num_chars < item->num_chars; num_chars++)
         {
+          extra_width = find_break_extra_width (layout, state, num_chars);
+
           if (width + extra_width > state->remaining_width && break_num_chars < item->num_chars)
-            {
-              break;
-            }
+            break;
 
           /* If there are no previous runs we have to take care to grab at least one char. */
           if (can_break_at (layout, state->start_offset + num_chars, retrying_with_char_breaks) &&
@@ -3931,11 +3932,7 @@ process_item (PangoLayout     *layout,
               break_num_chars = num_chars;
               break_width = width;
               break_extra_width = extra_width;
-
-              extra_width = find_break_extra_width (layout, state, num_chars);
             }
-          else
-            extra_width = 0;
 
           width += state->log_widths[state->log_widths_offset + num_chars];
         }


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