inscription: Do not try to align layouts that have a proper width set
authorBenjamin Otte <otte@redhat.com>
Mon, 13 Jun 2022 02:53:35 +0000 (04:53 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 13 Jun 2022 04:49:12 +0000 (06:49 +0200)
Pango knows where to put the text.

gtk/gtkinscription.c

index 5f13063fb601ef72a9e44e544e29b7a454cc266f..a06b78b30b9c26258f3cec1ce33990bad6dcc18e 100644 (file)
@@ -424,7 +424,10 @@ gtk_inscription_get_layout_location (GtkInscription *self,
     xalign = 1.0 - xalign;
 
   pango_layout_get_pixel_extents (self->layout, NULL, &logical);
-  x = floor ((xalign * (widget_width - logical.width)) - logical.x);
+  if (pango_layout_get_width (self->layout) > 0)
+    x = 0.f;
+  else
+    x = floor ((xalign * (widget_width - logical.width)) - logical.x);
 
   baseline = gtk_widget_get_allocated_baseline (widget);
   if (baseline != -1)