zoukankan      html  css  js  c++  java
  • Redmine 甘特图导出 PDF 和 PNG 中文乱码问题

    Redmine使用了RMagick来处理图片,fpdf处理PDF,并在调用时设定了字体
    PDF中文字体

    redmine 中关于PDF字体设置的代码

              case pdf_encoding
              when 'UTF-8'
                @font_for_content = 'FreeSans'
                @font_for_footer = 'FreeSans'
              when 'CP949'
                extend(PDF_Korean)
                AddUHCFont()
                @font_for_content = 'UHC'
                @font_for_footer = 'UHC'
              when 'CP932', 'SJIS', 'SHIFT_JIS'
                extend(PDF_Japanese)
                AddSJISFont()
                @font_for_content = 'SJIS'
                @font_for_footer = 'SJIS'
              when 'GB18030'
                extend(PDF_Chinese)
                AddGBFont()
                @font_for_content = 'GB'
                @font_for_footer = 'GB'
              when 'BIG5'
                extend(PDF_Chinese)
                AddBig5Font()
                @font_for_content = 'Big5'
                @font_for_footer = 'Big5'
              else
                @font_for_content = 'Arial'
                @font_for_footer = 'Helvetica'
              end

    在中文时,Redmine 使用了GB字体,在debian or Ubuntu系统中,可使用APT安装
    apt-get install ttf-arphic-bkai00mp ttf-arphic-bsmi00lp ttf-arphic-gbsn00lp ttf-arphic-gbsn00lp

    参考 http://isis.poly.edu/~qiming/chinese-debian-mini-howto.html
    图片中文问题(PNG)
    图片中文也是类似的原理,下面是Redmine config/configuration.yml 中的内容
    # This setting is not necessary in non CJK.
    #
    # Examples for Japanese:
    # Windows:
    # rmagick_font_path: C:windowsfontsmsgothic.ttc
    # Linux:
    # rmagick_font_path: /usr/share/fonts/ipa-mincho/ipam.ttf
    #
    rmagick_font_path:

    1>创建目录 /usr/share/fonts/truetype/arphic/

    2> 下载gbsn00lp.ttf.gz

    cd /tmp

    wget http://down1.chinaunix.net/distfiles/gbsn00lp.ttf.gz

    gunzip gbsn00lp.ttf.gz

    cp /tmp/gbsn00lp.ttf   /usr/share/fonts/truetype/arphic/

    3>修改这段代码,设定适当的中文字体路径即可,如:
    rmagick_font_path: /usr/share/fonts/truetype/arphic/gbsn00lp.ttf

    重新启动服务器,现在中文导出应当正常了。

    本文使用的Redmine版本为 3.3.0

  • 相关阅读:
    701. 二叉搜索树中的插入操作
    【ceph | 运维】 部署mgr
    【cpeh | 运维】mon相关命令
    【Leetcode】144. 二叉树的前序遍历
    【Linux】Linux中查看某个软件的安装路径
    【Leetcode】100. 相同的树
    【Leetcode】145. 二叉树的后序遍历
    【Leetcode】94. 二叉树的中序遍历
    redis学习04Redis的主从架构
    RabbitMQ学习02安装与配置(Ubuntu系统)
  • 原文地址:https://www.cnblogs.com/eos666/p/9431872.html
Copyright © 2011-2022 走看看