You can use TextLayout or don't use it. It's up to you.
Suppose you would like to start drawin from point x, y. You ot first letter (by substring) and draw it. The you have to add height of the letter to the y position and draw next letter.
g.getFontMetrics().getHeight(); //to get height
g.getFontMetrics().stringWidth("A"); //OR below
Sum of heights is your rect height. Max of letters' widths is your rect width.