[pango/line-height-attribute] Fix up cursor rectangles



commit 331a4542f09f744302ef2336ee874d1dfdacef6e
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Aug 7 21:02:36 2021 -0400

    Fix up cursor rectangles
    
    Now that lines can be extended vertically, we need
    to take the vertical extents from the ink rect. We
    still take the horizontal position from the logical
    rect in order to not change cursor placement.

 pango/pango-layout.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index d23ce5a6..2546e35a 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -1797,6 +1797,7 @@ pango_layout_index_to_line_and_extents (PangoLayout     *layout,
 {
   PangoLayoutIter iter;
   PangoLayoutLine *line = NULL;
+  PangoRectangle rect;
 
   _pango_layout_get_iter (layout, &iter);
 
@@ -1810,7 +1811,13 @@ pango_layout_index_to_line_and_extents (PangoLayout     *layout,
 
         line = tmp_line;
 
-        pango_layout_iter_get_line_extents (&iter, NULL, line_rect);
+        pango_layout_iter_get_line_extents (&iter, &rect, line_rect);
+
+        /* We use the vertical extents from the ink_rect, since the
+         * logical rect is affect by line_height.
+         */
+        line_rect->y = rect.y;
+        line_rect->height = rect.height;
 
         if (line->start_index + line->length > index)
           break;


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