From c754c4d686623757f09fe8184732dff495bea2a6 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 8 May 2021 23:27:07 -0400 Subject: Ensure ellipsized lines have the right width Otherwise, ellipsized text will 'vibrate', as the size changes. Fixes: #24 --- pango/ellipsize.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pango/ellipsize.c b/pango/ellipsize.c index 4eb98a1a..0d54483e 100644 --- a/pango/ellipsize.c +++ b/pango/ellipsize.c @@ -634,7 +634,8 @@ remove_one_span (EllipsizeState *state) * of the gap */ static void -fixup_ellipsis_run (EllipsizeState *state) +fixup_ellipsis_run (EllipsizeState *state, + int extra_width) { PangoGlyphString *glyphs = state->ellipsis_run->glyphs; PangoItem *item = state->ellipsis_run->item; @@ -650,6 +651,8 @@ fixup_ellipsis_run (EllipsizeState *state) glyphs->glyphs[0].attr.is_cluster_start = TRUE; + glyphs->glyphs[glyphs->num_glyphs - 1].geometry.width += extra_width; + /* Fix up the item to point to the entire elided text */ item->offset = state->gap_start_iter.run_iter.start_index; item->length = state->gap_end_iter.run_iter.end_index - item->offset; @@ -765,7 +768,7 @@ _pango_layout_line_ellipsize (PangoLayoutLine *line, break; } - fixup_ellipsis_run (&state); + fixup_ellipsis_run (&state, MAX (goal_width - current_width (&state), 0)); g_slist_free (line->runs); line->runs = get_run_list (&state); -- cgit v1.2.1