Java - FontMetrics without Graphics
2022-09-01 06:41:34
如何在不使用图形的情况下获得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();