For the record, setting the text size to TextWidth/TextHeight isn't necessarily going to fit the complete text in. Text metrics are actually super complicated. You have all sorts of different baselines (e.g. hanging, middle, alphabetic, ideographic...), different languages extend different distances above and below the line, certain unicode combinations can extend indefinitely in an upwards or downwards direction (e.g. z̻̗͜a̦̥̱͖̝͓͉l̡̤͕̟̝̟̻g͎̹o̡̫̲ text), and so on and on.
So when you say "how tall is the text?" it's not actually particular clear what you are measuring. Which baselines are you going from? Does it include all ascenders and descenders? Do you want it to keep extending with things like zalgo text? How do you make sure it never cuts off any of the text with any possible combination of text, font and languages?
This is compounded by the fact the web platform currently doesn't expose all the text metrics we need to answer all of these questions (as noted in this old issue about vertical text alignment).
This issue appears to refer to BBcode altering the text size not being taken in to account in the calculated text height, which is a different type of problem - but even if that's fixed, it still won't mean that setting the text size to TextWidth/TextHeight allows all the text to be visible, because of everything I just mentioned. Basically you just have to add some padding - but unfortunately at the moment there's no way to know how much padding is needed exactly, and it's different depending on the text/font/languages you want to cover. So, you'll just have to guess...