How to count the width of text sprite?

73 views Asked by At

I need to wrap text nicely. E.g. "WWWW WWWW" takes more space than "1111 1111". I have a design to make a for loop and add words one by one and see if text is too long to fit the row.

How to count properly the text.textWidth() without drawing text to the screen 1st?

System.Wait() seems to be required to make textwidth value refresh, is there any workaround for this? I don't want to add sleep into for loop, it would take ages.

1

There are 1 answers

0
b3253223b33v On
len(text.text) to count the text, use len(str(text.text)) if combinated number and text

checkout full documentation here