diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-11-21 16:20:25 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-11-22 23:32:35 -0500 |
commit | 0a1218ebb121a829b2a63ac98f36c28e594e124f (patch) | |
tree | f8d8664f1f4652c0ca777b78f90581891f8e7361 /pango/pango-layout.c | |
parent | 6655ceabff26f7830335833ace8e59e78251c296 (diff) | |
download | pango-0a1218ebb121a829b2a63ac98f36c28e594e124f.tar.gz |
Fix handling of extra widthline-breaking-fixes4
When handling items that fix completely,
we were not consistently taking extra width
into account, leading to hyphens sticking
out in some cases.
Diffstat (limited to 'pango/pango-layout.c')
-rw-r--r-- | pango/pango-layout.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 3cdb677a..a5806774 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -3930,15 +3930,29 @@ process_item (PangoLayout *layout, width += state->log_widths[state->log_widths_offset + i]; } - if ((width <= state->remaining_width || (item->num_chars == 1 && !line->runs)) && + if (!no_break_at_end && + can_break_at (layout, state->start_offset + item->num_chars, wrap)) + { + if (processing_new_item) + { + compute_log_widths (layout, state); + processing_new_item = FALSE; + } + + extra_width = find_break_extra_width (layout, state, item->num_chars); + } + else + extra_width = 0; + + if ((width + extra_width <= state->remaining_width || (item->num_chars == 1 && !line->runs)) && !no_break_at_end) { - DEBUG1 ("%d <= %d", width, state->remaining_width); + DEBUG1 ("%d + %d <= %d", width, extra_width, state->remaining_width); insert_run (line, state, item, NULL, FALSE); width = pango_glyph_string_get_width (((PangoGlyphItem *)(line->runs->data))->glyphs); - if (width <= state->remaining_width || (item->num_chars == 1 && !line->runs)) + if (width + extra_width <= state->remaining_width || (item->num_chars == 1 && !line->runs)) { state->remaining_width -= width; state->remaining_width = MAX (state->remaining_width, 0); @@ -4007,7 +4021,7 @@ retry_break: if (can_break_at (layout, state->start_offset + num_chars, wrap) && (num_chars > 0 || line->runs)) { - DEBUG1 ("possible breakpoint: %d", num_chars); + DEBUG1 ("possible breakpoint: %d, extra_width %d", num_chars, extra_width); if (num_chars == 0 || width + extra_width < state->remaining_width - safe_distance) { @@ -4044,10 +4058,13 @@ retry_break: if (num_chars > 0 && layout->log_attrs[state->start_offset + num_chars - 1].is_white) extra_width = - state->log_widths[state->log_widths_offset + num_chars - 1]; + else if (item == new_item && + break_needs_hyphen (layout, state, num_chars)) + extra_width = state->hyphen_width; else extra_width = 0; - DEBUG1 ("measured breakpoint %d: %d", num_chars, new_break_width); + DEBUG1 ("measured breakpoint %d: %d, extra %d", num_chars, new_break_width, extra_width); if (new_item != item) { @@ -5947,6 +5964,7 @@ add_missing_hyphen (PangoLayoutLine *line, int width; int start_offset; + DEBUG1("add a missing hyphen"); /* The last run fit onto the line without breaking it, but it still needs a hyphen */ width = pango_glyph_string_get_width (run->glyphs); |