字体 (Myanmar3) 在 iText 中无法正确呈现

Font (Myanmar3) not rendering correctly in iText

section there is this jasper-report-character-encoding-in-pdf问题中。

问题无法在 jasper 报告中解决,因为它似乎是一个 问题(使用 iText v. 5.5.4)

示例代码:

public class FontTest {

    /** The resulting PDF file. */
    public static final String RESULT = "pdf/fontTest.pdf";
    /** the text to render. */
    public static final String TEST = "\u1005\u101B\u1004\u103A\u1038\u1021\u1004\u103A\u1038\u1019\u103B\u102C\u1038\u1011\u100A\u103A\u101E\u103D\u1004\u103A\u1038\u1001\u103C\u1004\u103A\u1038";

    public void createPdf(String filename) throws IOException, DocumentException {
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        BaseFont bf = BaseFont.createFont(
            "lib/mm3.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        Font font = new Font(bf, 20);
        ColumnText column = new ColumnText(writer.getDirectContent());
        column.setSimpleColumn(36, 730, 569, 36);
        column.addElement(new Paragraph(TEST, font));
        column.go();
        document.close();
    }

    public static void main(String[] args) throws IOException, DocumentException {
        new FontTest().createPdf(RESULT);
    }
}

字体可以在mm3.ttf

下载

将错误地呈现为:

它应该呈现为(在使用相同 ttf 的浏览器中)

只是出于好奇发生了什么事? (似乎某些字符,带虚线的圆圈应该向后移动,但这没有发生)。

这是 .tff 的问题还是 iText 不支持这些字体?

Bruno Lowagie (Original developer of ) 评论转换为答案(社区维基)

您看到的行为是由于 iText 不支持连字。 (当前版本 github.com 5.5.8

您需要下一个未发布的 iText 版本。我们将在明年 (2016) 发布测试版,但仅面向客户

感谢 @Rad Lexus this other question about accessing directly openType glyph in iText has an answer

提供的赏金

请尝试以下代码,

string ZawgyiOnePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "ZawgyiOne.ttf");
            BaseFont ZawgyiOneBaseFont = BaseFont.CreateFont(ZawgyiOnePath, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

 iTextSharp.text.Font ZawgyiOneFont = new iTextSharp.text.Font(ZawgyiOneBaseFont, 9);