[pango/matthiasc/for-master] Fix a thinko



commit 0be035c456681e35304c110c42314fe42111d169
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun May 9 23:53:43 2021 -0400

    Fix a thinko
    
    The commit message for d476d2a944500f8553 said
    "word boundaries", but the code checked for line
    breaks. That was wrong, since it also made hyphens
    disappear at SHY, where we very much want them.
    
    Update affected tests.

 pango/pango-layout.c           | 10 ++++++----
 tests/layouts/valid-4.expected |  4 ++--
 2 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 2fe6c9dc..ca70ebe5 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -3511,6 +3511,8 @@ get_need_hyphen (PangoItem  *item,
     }
   _pango_attr_list_get_iterator (&attrs, &iter);
 
+  prev_space = prev_hyphen = TRUE;
+
   for (i = 0, p = text + item->offset; i < item->num_chars; i++, p = g_utf8_next_char (p))
     {
       gunichar wc = g_utf8_get_char (p);
@@ -3581,9 +3583,7 @@ get_need_hyphen (PangoItem  *item,
       else
         hyphen = FALSE;
 
-      if (i == 0)
-        need_hyphen[i] = FALSE;
-      else if (prev_space || space)
+      if (prev_space || space)
         need_hyphen[i] = FALSE;
       else if (prev_hyphen || hyphen)
         need_hyphen[i] = FALSE;
@@ -3594,6 +3594,8 @@ get_need_hyphen (PangoItem  *item,
       prev_hyphen = hyphen;
     }
 
+  need_hyphen[item->num_chars - 1] = FALSE;
+
   _pango_attr_iterator_destroy (&iter);
   _pango_attr_list_destroy (&attrs);
 }
@@ -3606,7 +3608,7 @@ break_needs_hyphen (PangoLayout    *layout,
   if (state->log_widths_offset + pos == 0)
     return FALSE;
 
-  if (layout->log_attrs[state->start_offset + pos].is_line_break)
+  if (layout->log_attrs[state->start_offset + pos].is_word_boundary)
     return FALSE;
 
   if (state->need_hyphen[state->log_widths_offset + pos - 1])
diff --git a/tests/layouts/valid-4.expected b/tests/layouts/valid-4.expected
index 2534b6fc..66796cb5 100644
--- a/tests/layouts/valid-4.expected
+++ b/tests/layouts/valid-4.expected
@@ -23,11 +23,11 @@ i=6, index=152, paragraph-start=1, dir=ltr ''
 
 --- runs
 
-i=1, index=0, chars=30, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'This 
paragraph should ac­tual­'
+i=1, index=0, chars=30, level=0, gravity=south, flags=4, font=OMITTED, script=latin, language=en-us, 'This 
paragraph should ac­tual­'
 i=2, index=32, no run, line end
 i=3, index=32, chars=31, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'ly 
have multiple lines, unlike '
 i=4, index=63, no run, line end
-i=5, index=63, chars=29, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'all 
the other wannabe äöü pa­'
+i=5, index=63, chars=29, level=0, gravity=south, flags=4, font=OMITTED, script=latin, language=en-us, 'all 
the other wannabe äöü pa­'
 i=6, index=96, no run, line end
 i=7, index=96, chars=27, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 
'ra­graph tests in this ugh '
 i=8, index=124, no run, line end


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