You can get the width of char or String displayed in a specific font with FontMetrics.stringWidth(). This should be the size in points. The point is 20 tweets.
So this should work:
Font font = new Font("Arial", Font.PLAIN, 10);
FontMetrics fm = new FontMetrics(font);
int widthInTwips = fm.stringWidth("Hello World") * 20;
source
share