对于复杂的脚本(在我的例子中是 Tibt),我需要能够指定 PdfFont 应该使用的一些 OpenType 功能(有关与 Tibt 一起使用的功能,请参见此处)。我找不到任何方法来指定 iText,并且使用默认功能,结果不好。
例子:
public static void main(String args[]) throws IOException {
final String notoPath = "/usr/share/fonts/truetype/noto/NotoSansTibetan-Regular.ttf";
final PdfWriter writer = new PdfWriter("tibttest.pdf");
final PdfDocument pdfDoc = new PdfDocument(writer);
final Document doc = new Document(pdfDoc);
PdfFont f = PdfFontFactory.createFont(notoPath, PdfEncodings.IDENTITY_H, true);
doc.add(new Paragraph("༄༅། །སྒྲུབ།").setFont(f));
doc.close();
}
生成的 PDF 如下所示:
虽然它应该看起来像:
有没有办法指定要使用的 OpenType 功能列表?
您在使用附加的 pdfCalligraph 吗?https://itextpdf.com/itext7/pdfcalligraph
如果是,那么您是拥有支持合同的 iText 客户,我建议您直接联系 iText Software。
如果不是:您需要 pdfCalligraph 才能使用 Tibt 等复杂书写系统的 OpenType 功能。请参阅链接网站上的扩展示例。因为我没有看到您在代码中加载许可证密钥,所以我认为是这种情况。
如果 pdfCalligraph 尚不支持您的特定语言,我们将确保尽快添加它。但在我看来,我认为大多数印度语言都受支持。您可以在https://pages.itextpdf.com/itext-7-free-trial-landing-page-1.html申请 30 天免费试用许可证
完全披露:我是 iText Software 的 QA 工程师。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句