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

  • 相关阅读:
    FastAdmin 开发时对数据库进行版本管理 (非 think-migration)
    使用 mysqldump 备份时的一些参数
    软件开源后可能遇到的问题
    基于 FastAdmin 开发后台流程 (持续更新)
    FastAdmin 怎么把模块设置默认的首页?
    FastAdmin 离线安装 ueditor 出现 rule 错误
    Windows nginx php cgi-fcgi 配置 xdebug
    FastAdmin 插件刷新缓存出现 200 红色提示框解决 always_populate_raw_post_data
    参与开源项目给我带来了什么?
    为什么要求将问题发到社区?
  • 原文地址:https://www.cnblogs.com/eos666/p/9431872.html
Copyright © 2011-2022 走看看