From 4b6a9d2fb5fcb2955a01b542c566e91bc39cac7c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 28 Jan 2023 10:30:04 -0500 Subject: [PATCH] tooltip: Don't play games with max-width-chars Setting max-width-chars to the number of characters in the string works ok only as long as the average char width we get from Pango matches reality. Sadly that seems not always the case, and this code was causing short Chinese tooltips to always be broken into two lines. Fixes: #4470 --- gtk/gtktooltipwindow.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gtk/gtktooltipwindow.c b/gtk/gtktooltipwindow.c index 491598a1f5..228a96f42b 100644 --- a/gtk/gtktooltipwindow.c +++ b/gtk/gtktooltipwindow.c @@ -413,11 +413,7 @@ update_label_width (GtkLabel *label) } else { - int len; - - len = g_utf8_strlen (text, -1); - - gtk_label_set_max_width_chars (label, MIN (len, 50)); + gtk_label_set_max_width_chars (label, 50); gtk_label_set_wrap (label, TRUE); } }