I am currently working on a project to mass-produce graphics such as you see below:
The part I want to be able to swap out with any other word is is "<Table">. For aesthetic reasons, I want this text to always be dead-center in the rounded rectangle. I am using Graphics2D to achieve this; here is the code that generated the text:
g2D.setColor(Color.WHITE);
int fontSize = 55;
int fontX = 410;
int fontY = 75;
g2D.setFont(new Font("Arial", Font.PLAIN, fontSize));
g2D.drawString("<Table>", fontX, fontY);
I am going to create a method that generates fontSize, fontX, and fontY based on what would make it centered. If all characters were the same width, I would obviously not need help, but I am wondering how to handle very thin characters such as "i". I am not asking for anyone to solve the problem for me or give me the answer; in fact I would like to be able to figure it out myself. However, I do want some pointer on what to research/look up in order to solve this problem, as well as other considerations I didn't consider.