iced
iced copied to clipboard
Calculating canvas text size
Hello,
I'm trying to display canvas::Text
next to a chart drawn on a canvas
. To get the spacing/padding around the text right, I need to know the amount of space the text will take up on the canvas.
I tried to read the source code and follow the program execution to see how the text gets drawn on the canvas in an attempt to implement this myself but didn't get anywhere. I am thankful for any help on this subject.
I think the way to go here is to provide a new argument to canvas::Program::draw
to perform text measurements.
I will try to tackle this soon.
I will try to tackle this soon.
Thank you very much!
I think the way to go here is to provide a new argument to canvas::Program::draw to perform text measurements.
I don't quite understand your train of thought. I envisioned a function like iced::widget::canvas::Text::size_on_canvas() -> Rectangle
where the Rectangle
would be the texts boundaries. Could you go into a bit more detail once you find the time?
I am also drawing charts and need text size measurement for layout. If it makes easier, only support for monospace + basic shaping is fine until the feature is fully implemented.