summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-11-12 18:05:17 -0500
committerMatthias Clasen <mclasen@redhat.com>2021-11-12 18:41:44 -0500
commitd98a4c78c5a57e2dd2d888f489971d8221e4d104 (patch)
treee95c3c841790976db1e3261d61f169628899761f
parentc435091fad16e00129aef2e15f64c9c8bd768102 (diff)
downloadpango-d98a4c78c5a57e2dd2d888f489971d8221e4d104.tar.gz
Fix another corner case of space-handling
This keeps spiraling :(
-rw-r--r--pango/pango-layout.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index ad16e918..c94617aa 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -3904,10 +3904,6 @@ process_item (PangoLayout *layout,
retry_break:
- /* See how much of the item we can stuff in the line. */
- width = 0;
- extra_width = 0;
-
/* break_extra_width gets normally set from find_break_extra_width inside
* the loop, and that takes a space before the break into account. The
* one case that is not covered by that is if we end up going all the way
@@ -3916,7 +3912,23 @@ process_item (PangoLayout *layout,
* initialize it here, taking space-before-break into account.
*/
if (layout->log_attrs[state->start_offset + break_num_chars - 1].is_white)
- break_extra_width = - state->log_widths[state->log_widths_offset + break_num_chars - 1];
+ {
+ break_extra_width = - state->log_widths[state->log_widths_offset + break_num_chars - 1];
+
+ /* check one more time if the whole item fits after removing the space */
+ if (width + break_extra_width <= state->remaining_width && !no_break_at_end)
+ {
+ state->remaining_width -= width + break_extra_width;
+ state->remaining_width = MAX (state->remaining_width, 0);
+ insert_run (line, state, item, TRUE);
+
+ return BREAK_ALL_FIT;
+ }
+ }
+
+ /* See how much of the item we can stuff in the line. */
+ width = 0;
+ extra_width = 0;
for (num_chars = 0; num_chars < item->num_chars; num_chars++)
{