DITA-OT中PDF输出的中文支持
DITA-OT本身对国际化已经有较好的支持,所以在输出PDF时,只需要不多的调整,就可以支持中文。
源文件语言
为使DITA-OT在输出PDF时确定使用的字体,首先需要为DITA源文件指定语言,可以基于xml:lang
属性实现,例如:
<topic id="topic" xml:lang="zh-cn">...</topic>
中文编码范围
DITA-OT(3.6.1版本)在框定中文编码范围时,未包含全角符号,同时又多框定了部分非中文的符号,导致部分符号无法显示,可以在plugins/org.dita.pdf2/cfg/fo/i18n/zh_CN.xml文件中,将0100
-ff00
这段字符范围调整为如下范围:
<character-range>
<start include="yes"> </start>
<end include="yes">〿</end>
</character-range>
<character-range>
<start include="yes">＀</start>
<end include="yes">￯</end>
</character-range>
中文字体映射
中文字体的映射可以通过调整plugins/org.dita.pdf2/cfg/fo/font-mappings.xml文件实现,示例如下(其中使用的字体在Ubuntu环境中可以通过fonts-cmu
、fonts-wqy-microhei
、fonts-arphic-gbsn00lp
和fonts-arphic-gkai00mp
包安装):
<font-mappings>
<font-table>
<logical-font name="sans-serif">
<physical-font char-set="default"><font-face>CMU Sans Serif</font-face></physical-font>
<physical-font char-set="Simplified Chinese"><font-face>WenQuanYi Micro Hei</font-face></physical-font>
</logical-font>
<logical-font name="serif">
<physical-font char-set="default"><font-face>CMU Serif</font-face></physical-font>
<physical-font char-set="Simplified Chinese"><font-face>AR PL SungtiL GB</font-face></physical-font>
</logical-font>
<logical-font name="monospace">
<physical-font char-set="default"><font-face>CMU Typewriter Text</font-face></physical-font>
<physical-font char-set="Simplified Chinese"><font-face>AR PL KaitiM GB</font-face></physical-font>
</logical-font>
</font-table>
</font-mappings>