Java - FontMetrics without Graphics
Posted
by subSeven
on Stack Overflow
See other posts from Stack Overflow
or by subSeven
Published on 2010-05-16T11:54:02Z
Indexed on
2010/05/16
12:00 UTC
Read the original article
Hit count: 280
Hello! How to get FontMetrics without use Graphics ? I want to get FontMetrics in constructor, now I do this way:
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();
© Stack Overflow or respective owner