本帖最后由 daichangfu 于 2013-09-06 08:46:23 编辑

解决方案 »

  1.   

    个人觉得应该是Linux 系统的问题
      

  2.   

    LINUX默认UTF8,win7是GBK……该不是你的程序开发时语言环境不对?
      

  3.   


    我的项目文件整体都是UTF-8的,你说的这个问题不存在。
      

  4.   

    那Linux系统里支持中文编码吗?
      

  5.   

    /**
     * 把字符印到图片上
     * @param imgPath 图片路径(物理路径)
     * @param text 准备的字符
     * @param font 字体样式
     * @param color 字体颜色
     * @param left 图片的x坐标 (印的位置)
     * @param top 图片的y坐标 (印的位置)
     */
    public void fontImg(String imgPath, String text, Font font, Color color, int left, int top) {
    try {
    BufferedImage src = ImageIO.read(new File(imgPath));
                int width = src.getWidth();
                int height = src.getHeight();
                BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
                Graphics graph = image.createGraphics();
                graph.drawImage(src, 0, 0, width, height, null);
                graph.setColor(color);
                graph.setFont(font);
                graph.drawString(text, left, top);
                graph.dispose();
                FileOutputStream out = new FileOutputStream(imgPath);
                JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
                encoder.encode(image);
                out.close();
                image.flush();
                src.flush();
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
      

  6.   

    感觉不像是乱码,倒像是没那种字体。
    Linux上有宋体吗?
      

  7.   

    【问题解决了】 
    Linux上需要安装中文字体,
    JRE里面也要安装中文字体的,
    在$JAVA_HOME/jre/lib/fonts下新建一个fallback目录,复制程序用到的字体进去。
    参考资料:http://ginge.iteye.com/blog/640693