|
AWT drawString doesn't work on Linux
Hi *,
I have a little program which lets me make an image from a string and write it in a file. It works well on my XP but on my Linux server only the background pink is generated but no text (see attachment) . I also tried to set the Font but it didn't help. Any Ideas?
Hier is the code:
public static void textToImage4() throws IOException {
int width = 200, height = 135;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.setColor(Color.pink);
g.fillRect(0, 0, width, height);
// Font font = new Font("SERIF", Font.BOLD, 18);
// g2.setFont(font);
g.setColor(Color.black);
g.drawString("test", 46 , 54);
g.dispose();
ImageIO.write(image, "jpg", new File("test.jpg"));
}
I run the program with: java -Djava.awt.headless=true ...
thanks,
dishab
|