[pango/block-cursor-fixes: 3/4] layout: Fix some end-of-line position




commit ee44512da69e479f4af6c69b6113d6974042e6dc
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Aug 20 01:38:03 2021 -0400

    layout: Fix some end-of-line position
    
    Make pango_layout_index_to_pos report non-empty
    rectangles at the end of a line.

 pango/pango-layout.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index ac7eaab0..5ae46f85 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -2394,10 +2394,10 @@ pango_layout_index_to_pos (PangoLayout    *layout,
 
           if (tmp_line->start_index > index)
             {
-              /* index is in the paragraph delim&iters, move to
+              /* index is in the paragraph delimiters, move to
                * end of previous line
                *
-               * This shouldn’t occur in the first loop &iteration as the first
+               * This shouldn’t occur in the first loop iteration as the first
                * line’s start_index should always be 0.
                */
               g_assert (layout_line != NULL);
@@ -2409,20 +2409,21 @@ pango_layout_index_to_pos (PangoLayout    *layout,
 
           layout_line = tmp_line;
 
-          if (layout_line->start_index + layout_line->length > index)
+          if (layout_line->start_index + layout_line->length >= index)
             {
-              while (TRUE)
+              do
                 {
                   PangoLayoutRun *run = _pango_layout_iter_get_run (&iter);
 
                   pango_layout_iter_get_run_extents (&iter, NULL, &run_logical_rect);
 
-                  if (run->item->offset <= index && index < run->item->offset + run->item->length)
+                  if (!run)
                     break;
 
-                  if (!pango_layout_iter_next_run (&iter))
+                  if (run->item->offset <= index && index < run->item->offset + run->item->length)
                     break;
-                }
+                 }
+               while (pango_layout_iter_next_run (&iter));
 
               break;
             }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]