将中文显示在图片上,一定要指定中文字体吗?BufferedImage image = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, width, height);
g.setColor(Color.black);
g.drawRect(0, 0, width, height);
String text=request.getParameter("text");//通过request取中文参数,正常
if(text==null)text="";
g.setColor(Color.black); g.setFont(new Font("hanzigb16st", Font.PLAIN, 12));
//图片上中文显示乱码,这里一定要指定中文字体吗? g.drawString(text, 2, 14);
g.dispose();
g.setColor(Color.white);
g.fillRect(0, 0, width, height);
g.setColor(Color.black);
g.drawRect(0, 0, width, height);
String text=request.getParameter("text");//通过request取中文参数,正常
if(text==null)text="";
g.setColor(Color.black); g.setFont(new Font("hanzigb16st", Font.PLAIN, 12));
//图片上中文显示乱码,这里一定要指定中文字体吗? g.drawString(text, 2, 14);
g.dispose();
你试试把你的中文用utf-8转码看看
现上传到linux服务器,转码后图片显示඀ൢ
是不是因为服务器不支持utf-8或是中文?