请注意,我在使用 api fop 1.0 (XSL-FO) 以 PDF 格式生成的报告中显示阿拉伯语时遇到问题。
我配置了 userConfig.xml 以使用 Arial.ttf 字体。除了字符单独显示之外,一切正常。
示例: Ê ق ց 代替 Фقց
我加空格只是为了向你解释。
<fo:block-container font-size="12pt" writing-mode="rl-tb" xml:lang="ar" font-family="Arial" xmlns:fo="http://www.w3.org/1999/XSL/Format" >
<fo:block>
تقول
</fo:block>
</fo:block-container>
我尝试使用该标签,但其内容没有出现在生成的文档中。
<fo:block text-align="center">
<fo:inline direction="rtl" language="ar" unicode-bidi="embed">
تقول
</fo:inline>
</fo:block>
用户配置.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Arial Unicode only -->
<fop version="1.0">
<renderers>
<renderer mime="application/pdf">
<fonts>
<!-- register a particular font -->
<font kerning="yes"
embed-url="file:///C:\windows\arial.ttf"
encoding-mode="single-byte">
<font-triplet name="Arial" style="normal" weight="normal"/>
</font>
</fonts>
</renderer>
</renderers>
</fop>
谢谢你。
FOP 中可能会禁用对阿拉伯语和其他复杂脚本的支持,请参阅FOP 复杂脚本。
如果启用它们,设置 lang="ar" 就足够了。
complex-scripts-disabled 应该是“false”
我面临同样的问题并尝试了一切,但没有任何效果。
我遇到了this答案,OP面临着与我们完全相反的问题。在他的例子中,阿拉伯文本显示正确,但当他尝试在根标签中添加
xml:lang="ar"
时,所有字母都变得分开了。
因此,我从 XSL-FO 文件中删除了所有
xml:lang="ar"
和 language="ar"
,瞧,它成功了。现在,所有的字母都按照我的意愿连接起来了。尝试从代码中删除这些标签一次。
<fo:block-container font-size="12pt" writing-mode="rl-tb" font-family="Arial" xmlns:fo="http://www.w3.org/1999/XSL/Format" >
<fo:block>
تقول
</fo:block>
</fo:block-container>