2

我对 DITA OT 很陌生。下载了 DITA-OT1.5.4_full_easy_install_bin 并使用它。我正在尝试将简体中文 (zh-CN) 中的几个字符打印到 PDF 中。我看到这些字符在 XHTML 中正确打印,但在 PDF 中它们打印为“#”。

在命令行中,我看到了这个 - “警告:字形“?”(0x611f)在字体“Helvetica”中不可用。

以下是我迄今为止尝试过的事情:

在 demo\fo\fop\conf\fop.xconf :

<fonts>
     <font kerning="yes" 
         embed-url="file:///C:/Windows/Fonts/simsun.ttc" 
         embedding-mode="subset" encoding-mode="cid">
             <font-triplet name="SimSun" style="normal" weight="normal"/>
     </font>
     <auto-detect/>
     <directory recursive="true">C:\Windows\Fonts</directory>
</fonts>

在 demo\fo\cfg\fo\attrs\custom.xsl :

<xsl:attribute-set name="__fo__root">
     <xsl:attribute name="font-family">SimSun</xsl:attribute>
</xsl:attribute-set>

在 demo\fo\cfg\fo\font-mapping.xml 中为 Sans、Serif 和 Monospaced 逻辑字体添加了这个块:

<physical-font char-set="Simplified Chinese">
     <font-face>SimSun</font-face>
</physical-font>

在 samples\concepts\garageconceptsoverview.xml 中:

<shortdesc xml:lang="zh_CN">職業道德感.</shortdesc>
这是我用来生成 PDF 的命令:
ant -Dargs.input=samples\hierarchy.ditamap -Dtranstype=pdf

任何帮助,将不胜感激。谢谢。

[编辑] 我看到在 temp 文件夹中生成的 topic.fo 文件确实包含正确的中文字符。像这样:

<fo:block font-size="10pt" keep-with-next.within-page="5" start-indent="25pt">職業道德感.</fo:block>

但我在本文档的任何地方都没有看到与字体相关的信息。

4

3 回答 3

2

首先,您应该在所有 DITA 主题和映射的根元素上设置“xml:lang='zh_CN'”属性。这将有助于 DITA OT 发布决定用于静态文本(如“Table X”)的语言,并决定用于字体映射的字符集。然后您应该通过将参数“clean.temp”参数设置为“no”来运行发布。发布后,您可以在临时文件夹中查找名为“topic.fo”的文件,并在其中查看使用的字体系列。因为即使您在根元素上设置了字体,XSL-FO 文件中的其他位置也会明确设置字体系列。因此,与其在 XSL-FO 根元素上设置字体,不如编辑字体映射 XML 文件并为每个逻辑字体“Sans”

<logical-font name="Sans">
.........
  <physical-font char-set="Simplified Chinese">
    <font-face>SimSun</font-face>
  </physical-font>
  ......
</logical-font>

有关字体映射如何工作的更多信息:

https://www.oxygenxml.com/doc/versions/17.0/ug-editor/#topics/DITA-map-set-font-Apache-FOP.html

更新:如果您坚持将“SimSun”字体设置为根元素上的字体系列的 XSLT 自定义,那么在 font-mappings.xml 中,您需要为您的别名定义一个新映射:

<aliases>
  <alias name="SimSun">SimSun</alias>
</aliases>

然后将逻辑字体映射到相同 font-mappings.xml 中的物理字体:

<logical-font name="SimSun">
  <physical-font char-set="Simplified Chinese">
    <font-face>SimSun</font-face>
  </physical-font>
</logical-font>
于 2015-12-11T06:40:27.763 回答
1

0x611f ,这个字符是汉字(感), helvetica 是欧洲字体,所以“helvetica”字体中没有这个字符。你可以搜索这个“helvetica”字体位置,在这个位置你的内容(ditamap/dita)应该使用中文字体,而不是欧洲字体。您必须找到包含 [font-famliy=helvetical] 的 arritbute,在您自己的插件 [SimSun, Helvetical] 中进行修改。

于 2019-11-08T15:31:10.390 回答
0

抱歉,我无法回答您的问题,但您应该明确地从http://dita-ot.github.io/尝试更新的 DITA-OT 。不再支持您的 DITA-OT。使用最新版本,您的问题可能会消失。

于 2015-12-10T11:44:14.740 回答