Resize text rect

I would like to calculate the height of a box filled with text from a string. This needs to be calculated every time because different lengths of string variables can be passed into it. When I fill my scrolling window with the text, I would like it’s height to resize so that there is not too much empty space after the text ends or that it is too short it cuts the text off before completing.

I have a string of text, a rect with a particular width, and the font size.

Using GUIStyle.CalcHeight tells me that my image length is much shorter than what it actually needs to be.
I haven’t been able to find any other functions in Unity that could help me reach the answer I am looking for.

Anyone know a good equation or shortcut that I can use to get this right?

Perhaps you are looking for GUIStyle.CalcSize. Ensure the GUIStyle has the font set beforehand.