[pango/wip/baedert/for-master: 1/2] layout: Ignore setting the width if it won't have any effect



commit 54e4dfd1eae3933b24ed095cda2bff925d6c9a42
Author: Timm Bäder <mail baedert org>
Date:   Tue Apr 14 10:09:20 2020 +0200

    layout: Ignore setting the width if it won't have any effect
    
    This is a pretty weak check (think e.g. a layout containing the text
    "a\na"), but it's very easy to do and still hits quite a few cases in
    real-world applications.

 pango/pango-layout.c | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 44d59367..872ccd71 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -362,6 +362,11 @@ pango_layout_set_width (PangoLayout *layout,
   if (width != layout->width)
     {
       layout->width = width;
+
+      /* Increasing the width can only decrease the line count */
+      if (layout->line_count == 1 && width > layout->width)
+        return;
+
       layout_changed (layout);
     }
 }


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