label: Another tweak to wrapping handling
authorMatthias Clasen <mclasen@redhat.com>
Wed, 2 Aug 2023 14:50:03 +0000 (14:50 +0000)
committerEmmanuele Bassi <ebassi@gnome.org>
Wed, 2 Aug 2023 15:32:15 +0000 (16:32 +0100)
This fixes a few reftests that were failing after
the previous change because they ended up with x == -1.

gtk/gtklabel.c

index 9f1d993b0d1af2a98935ee87151042c10fedd868..8d59efe0c1abee5bd607d2625ebeda1d48e51e0e 100644 (file)
@@ -1333,10 +1333,9 @@ get_layout_location (GtkLabel  *self,
     xalign = 1.0 - xalign;
 
   pango_layout_get_pixel_extents (self->layout, NULL, &logical);
-  if (pango_layout_get_width (self->layout) > 0)
+  x = floor ((xalign * (widget_width - logical.width)) - logical.x);
+  if (x < 0)
     x = 0.f;
-  else
-    x = floor ((xalign * (widget_width - logical.width)) - logical.x);
 
   baseline = gtk_widget_get_baseline (widget);
   if (baseline != -1)