[pango/fix-ellipsized-line-width] Ensure ellipsized lines have the right width




commit 127d9e600da1cc22403c187692cac0374d68c58f
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..cdeca816 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, goal_width - current_width (&state));
 
   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]