From 2cd9c4b416cbe55dd68106003f360e861a6722be Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 25 Dec 2009 16:00:11 +0100 Subject: Zero the space at the end of line when breaking lines Previously we were not zeroing the final space in the line when breaking lines and were doing that only after lines were broken. This was broken since setting layout width to its own logical width (under width=-1) could result in differently broken lines. That's fixed now. Problem originally reported on gtk-list on 2009-12-22 by Ben Pfaff. --- pango/pango-layout.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 42de439b..df8207c3 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -3307,6 +3307,16 @@ process_item (PangoLayout *layout, width += state->log_widths[state->log_widths_offset + num_chars]; } + /* If there's a space at the end of the line, include that also. + * The logic here should match zero_line_final_space(). + * XXX Currently it doesn't quite match the logic there. We don't check + * the cluster here. But should be fine in practice. */ + if (break_num_chars > 0 && break_num_chars < item->num_chars && + layout->log_attrs[state->start_offset + break_num_chars - 1].is_white) + { + break_width -= state->log_widths[state->log_widths_offset + break_num_chars - 1]; + } + if (layout->wrap == PANGO_WRAP_WORD_CHAR && force_fit && break_width > state->remaining_width && !retrying_with_char_breaks) { retrying_with_char_breaks = TRUE; -- cgit v1.2.1