pdf - DITA OT 在 PDF 中打印 '#' 而不是汉字

标签 pdf dita dita-ot

我对 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 逻辑字体添加了此 block :

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

在示例\concepts\garageconceptsoverview.xml中:

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

如有任何帮助,我们将不胜感激。谢谢。

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

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

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

最佳答案

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

<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

更新: 如果您坚持进行 XSLT 自定义,将“SimSun”字体设置为根元素上的字体系列,那么您需要在 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>

关于pdf - DITA OT 在 PDF 中打印 '#' 而不是汉字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34198296/

相关文章:

xml - 如何覆盖 DITA 映射中的 keydef?

css - 在 Safari 上无边框打印

java - 签署 PDF 文档并以字节或流的形式获取 pdf

pdf - 寻找一款轻量级的pdf阅读器

xml - DITA XML : How can I add a link to the table of contents?

ant - 从 ditamap 创建 MERGED 文件然后过滤它

selenium - 与 Selenium 2 中的 PDF 弹出窗口交互

c# - XPath normalize-space() 不能作为阶梯函数工作?

dita - 当我不编写计算机文档时,我使用哪种 DITA 主题类型?

dita - 可以使用 CSS 文件生成 PDF 输出吗?