Label.get_text_metrics returns old metrics right after setting text

If I call label.get_text_metrics() immediately after label.set_text(), I get the metrics for the old text. Calling label.get_text_metrics() in the next frame seems to work, though.

1 Like

Yeah, this sounds like a bug. @Mathias_Westerdahl?

Well, the label.set_text() uses message passing, and the label. get_text_metrics() doesn’t. That’s why they work as they do. Granted

Ideally, I’d have something like a label.calc_text_metrics(font, text), but currently, we don’t have a way to reference the font object to pass in there. Hmm, maybe if we also had a label.get_font()… I’ll discuss this with the team next week.

7 Likes

Just encountered the same problem. Any update on this @Mathias_Westerdahl ?

We’re waiting for another task to be completed: “resource properties”
Then I can rewrite the label.get_text_metrics() given an actual font.
The resource properties has been delayed quite a bit, but thry’re still part of our roadmap

3 Likes