summaryrefslogtreecommitdiff
path: root/pango/pango-layout.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-11-12 17:21:44 -0500
committerMatthias Clasen <mclasen@redhat.com>2021-11-12 18:41:43 -0500
commitc435091fad16e00129aef2e15f64c9c8bd768102 (patch)
treed72295e14843fb2e9dea45fb1a783df1f1df5fdc /pango/pango-layout.c
parent86303ad26445ce7f7490f7e7a6690c611d83ea5e (diff)
downloadpango-c435091fad16e00129aef2e15f64c9c8bd768102.tar.gz
Fix up one more case of break-after-space
If the break is at the end of the item, we were forgetting to check for the space before the break.
Diffstat (limited to 'pango/pango-layout.c')
-rw-r--r--pango/pango-layout.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index b605ded5..ad16e918 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -3907,6 +3907,17 @@ process_item (PangoLayout *layout,
/* 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
+ * through the loop without ever entering the can_break_at case, and come
+ * out at the other end with the break_extra_width value untouched. So
+ * 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];
+
for (num_chars = 0; num_chars < item->num_chars; num_chars++)
{
extra_width = find_break_extra_width (layout, state, num_chars);
@@ -3927,17 +3938,6 @@ 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 + break_extra_width > state->remaining_width && !retrying_with_char_breaks)
{
retrying_with_char_breaks = TRUE;