Java在linux系统中输出汉字为方框???
在Windows下用JB9编程序,生成一张png图形,代码如下:
void loadimage()
{
BufferedImage img;
int maxImageWidth=300;
int maxImageHeight=200;
img = new BufferedImage(maxImageWidth, maxImageHeight,
java.awt.image.BufferedImage.TYPE_INT_ARGB);
img.getGraphics().setColor(Color.white);
img.getGraphics().fillRect(0, 0, maxImageWidth, maxImageHeight);
String tt="汉字word";
drawtext(img.getGraphics(),tt,x1,maxImageHeight-45,Color.red);
File file = new File("image.png");
FileOutputStream fout = null;
try {
fout = new FileOutputStream(file);
javax.imageio.ImageIO.write(img, "PNG", fout);
fout.close();
}
catch (IOException ex2) {
}
fout = null;
file = null;
img = null;
}
void drawtext(Graphics g,String text,int x,int y,Color color)
{
Font font;
font = new Font("宋体", 0, 12);
g.setFont(font);
g.setColor(color);
g.drawString(text,x,y);
}
生成图片文件image.png在windows系统中结果正常,但是把程序放到linux系统中运行生成的图片中的“汉字”就变成了方框了
请这方面的高手能给予解决