I have a `javax.swing.text.Document` and I want to calculate the size of the bounding box that document needs to render itself.

Is that possible? 

It is almost trivial for plain text (`height = line count * line height`, `width = max width over each line`) But how can I do this with RTF, HTML or any other document?