Graphics を使用せずに FontMetrics を取得するには? コンストラクターで FontMetrics を取得したいので、次のようにします。
BufferedImage bi = new BufferedImage(5, 5, BufferedImage.TYPE_INT_RGB);
FontMetrics fm = bi.getGraphics().getFontMetrics(font);
int width = fm.stringWidth(pattern);
int height = fm.getHeight();