int width)
{
GtkLabelPrivate *priv = label->priv;
+ PangoRectangle rect;
PangoLayout *copy;
if (existing_layout != NULL)
return priv->layout;
}
+ /* oftentimes we want to measure a width that is far wider than the current width,
+ * even though the layout is not wrapped. In that case, we can just return the
+ * current layout, because for measuring purposes, it will be identical.
+ */
+ pango_layout_get_extents (priv->layout, NULL, &rect);
+ if ((width == -1 || rect.width <= width) &&
+ !pango_layout_is_wrapped (priv->layout))
+ {
+ g_object_ref (priv->layout);
+ return priv->layout;
+ }
+
copy = pango_layout_copy (priv->layout);
pango_layout_set_width (copy, width);
return copy;