Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rendering text in an image in Java

Are there any nice libraries to render text in an image for Java?

Java has a 2d text library, http://java.sun.com/docs/books/tutorial/2d/text/index.html but not sure if theres a better library to use.

like image 933
JavaRocky Avatar asked Dec 13 '22 22:12

JavaRocky


1 Answers

Here's a method to draw text on an image:

public void displayText(BufferedImage image, String text, Font font, int x, int y){
   Graphics2d g = image.createGraphics();
   g.setFont(font);
   g.drawString(text, x, y);
   g.dispose();
}
like image 141
Jay Askren Avatar answered Jan 03 '23 00:01

Jay Askren