You know the size in pixels of your text object. You can know the number of characters of your text thanks to the .
Divide one by the other, and you should be able to determine the text size you need.
I don't think you are correct.
Yes, I know the size in pixels of the text object.
Yes, I know the number of characters of the text line.
From this, I can tell what size in pixels each char should be, but this is not the correct value of the "font size" to be used.