[pango/ltr-line-breaking-fixes: 9/11] Fix up one more case of break-after-space
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/ltr-line-breaking-fixes: 9/11] Fix up one more case of break-after-space
- Date: Fri, 12 Nov 2021 23:41:57 +0000 (UTC)
commit c435091fad16e00129aef2e15f64c9c8bd768102
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Nov 12 17:21:44 2021 -0500
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.
pango/pango-layout.c | 22 +++++++++++-----------
1 file 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]