summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-05-08 23:27:07 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-05-08 23:50:14 -0400
commitc754c4d686623757f09fe8184732dff495bea2a6 (patch)
tree13499617df2a0ebbd52d6f455684430960ccf7b2 /pango
parentb3ebe097a3042737165ba497dc5b08f235df8167 (diff)
downloadpango-c754c4d686623757f09fe8184732dff495bea2a6.tar.gz
Ensure ellipsized lines have the right widthfix-ellipsized-line-width
Otherwise, ellipsized text will 'vibrate', as the size changes. Fixes: #24
Diffstat (limited to 'pango')
-rw-r--r--pango/ellipsize.c7
1 files 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);