Hi, does anyone know what’s the recomended way of getting the height of a width restrained Paragraph
(with Wrap { trim: false }
) before rendering it?
Paragraph::line_count() is what you need.
It’s marked as unstable mainly because we don’t like the internal implementation of the wrapping too much (it’s fairly complex / convoluted), so we’d prefer to have a good way out if we need to change that code fundamentally in a way that would break this method. E.g. perhaps instead of an int, passing in config for textwrap might be the way to make this work nicer (just an example - not a plan).
I wouldn’t let that deter from using it however as we don’t have current plans to change this in the currentversion.
The alternative is to pre-wrap your text using the textwrap crate.