[pango/fix-ellipsized-line-width] Ensure ellipsized lines have the right width
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/fix-ellipsized-line-width] Ensure ellipsized lines have the right width
- Date: Sun, 9 May 2021 03:50:44 +0000 (UTC)
commit c754c4d686623757f09fe8184732dff495bea2a6
Author: Matthias Clasen <mclasen redhat com>
Date: Sat May 8 23:27:07 2021 -0400
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]