如何在不使用 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();