I'm trying to render the text's frame to fit around the text snugly. I'm able to calculate the desired height of the text frame, but simply doing that causes the text to not be in the frame. I need to be able to do this without modifying the font's attributes such as line height, and the text should not be cut off past the frame.
For example, this is how text and its frame look to start with:
I want to achieve something like this (without changing the line height and notice the text isn't cut off):