[pango/pango2: 110/201] layout: Go back to trimming start and end




commit c21e1606daa01eb06398a4262b6841a119aabd0c
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jan 25 22:25:57 2022 -0500

    layout: Go back to trimming start and end
    
    We want the first and the last line of the paragraph
    to have its leading trimmed, for the purposes of
    determining the paragraph extents.

 pango/pango-layout.c          | 9 ++++++++-
 tests/layouts/no-space.layout | 2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index c218422e..ba96589c 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -653,6 +653,7 @@ ensure_lines (PangoLayout *layout)
       PangoRectangle ext;
       int offset;
       PangoEllipsizeMode ellipsize = PANGO_ELLIPSIZE_NONE;
+      PangoLeadingTrim trim = PANGO_LEADING_TRIM_NONE;
 
       if ((line_no == 0) == (layout->indent > 0))
         {
@@ -670,7 +671,13 @@ ensure_lines (PangoLayout *layout)
 
 retry:
       line = pango_line_breaker_next_line (breaker, x, width, layout->wrap, ellipsize);
-      pango_line_get_extents (line, NULL, &ext);
+
+      if (line->starts_paragraph)
+        trim |= PANGO_LEADING_TRIM_START;
+      if (line->ends_paragraph)
+        trim |= PANGO_LEADING_TRIM_END;
+
+      pango_line_get_trimmed_extents (line, trim, &ext);
 
       if (layout->height >= 0 && y + 2 * ext.height >= layout->height &&
           ellipsize != layout->ellipsize)
diff --git a/tests/layouts/no-space.layout b/tests/layouts/no-space.layout
index 8ce55374..010cc56a 100644
--- a/tests/layouts/no-space.layout
+++ b/tests/layouts/no-space.layout
@@ -76,7 +76,7 @@
       {
         "position" : [
           0,
-          40448
+          38912
         ],
         "line" : {
           "start-index" : 0,


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