C
Chase Preuninger
BufferedImage img = new BufferedImage(50 * text.length(), 100,
BufferedImage.TYPE_3BYTE_BGR);
Graphics2D g = img.createGraphics();
FontMetrics fm = g.getFontMetrics(f);
g.setBackground(Color.WHITE);
g.clearRect(0, 0, img.getWidth(), img.getHeight());
g.setFont(f);
g.setColor(Color.BLACK);
g.drawString(text, 50, fm.getAscent() + 10);
How can I tell how big to make my image based on the font and text?
BufferedImage.TYPE_3BYTE_BGR);
Graphics2D g = img.createGraphics();
FontMetrics fm = g.getFontMetrics(f);
g.setBackground(Color.WHITE);
g.clearRect(0, 0, img.getWidth(), img.getHeight());
g.setFont(f);
g.setColor(Color.BLACK);
g.drawString(text, 50, fm.getAscent() + 10);
How can I tell how big to make my image based on the font and text?