diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-08-26 01:14:07 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-08-26 08:02:07 -0400 |
commit | 653e27a8dc6cb25042d811be7f6d962d50233dbe (patch) | |
tree | 657b5a34a241408649eabd2dddde2d2b62592114 /pango/break.c | |
parent | 0c685b192f46c9455afab301346284e7d426fd5e (diff) | |
download | pango-653e27a8dc6cb25042d811be7f6d962d50233dbe.tar.gz |
break: Fix up word fixups
We were not correctly handling overlapping segments
in all cases, with <span segment='word'>. Improve this.
Update affected tests.
Diffstat (limited to 'pango/break.c')
-rw-r--r-- | pango/break.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/pango/break.c b/pango/break.c index 369a2cb4..0cb6666d 100644 --- a/pango/break.c +++ b/pango/break.c @@ -1867,11 +1867,14 @@ handle_words (const char *text, if (start >= offset) { gboolean in_word = FALSE; - for (pos = start_pos - 1; pos >= 0; pos--) + for (pos = start_pos; pos >= 0; pos--) { if (log_attrs[pos].is_word_end) - break; - if (log_attrs[pos].is_word_start) + { + in_word = pos == start_pos; + break; + } + if (pos < start_pos && log_attrs[pos].is_word_start) { in_word = TRUE; break; @@ -1882,7 +1885,8 @@ handle_words (const char *text, log_attrs[start_pos].is_word_boundary = TRUE; /* Allow line breaks before words */ - log_attrs[start_pos].is_line_break = TRUE; + if (start_pos > 0) + log_attrs[start_pos].is_line_break = TRUE; tailored = TRUE; } @@ -1890,11 +1894,14 @@ handle_words (const char *text, if (end < offset + length) { gboolean in_word = FALSE; - for (pos = end_pos + 1; pos < log_attrs_len; pos++) + for (pos = end_pos; pos < log_attrs_len; pos++) { if (log_attrs[pos].is_word_start) - break; - if (log_attrs[pos].is_word_end) + { + in_word = pos == end_pos; + break; + } + if (pos > end_pos && log_attrs[pos].is_word_end) { in_word = TRUE; break; |