Is it possible to get a text's extent?

In order to avoid shifting layouts, I’d like to set the width of a text widget to a size determined at run-time based on a given fixed string. In GTK this is relatively easy via Pango and pango_layout_get_pixel_extents(). Is there something similar in Iced?

There is no widget that does this, but building a custom one should be possible.

text::Renderer can measure text.

1 Like