Bengli 文本上的 iText7 排版 IndexOutOfBoundsException

iText7 typography IndexOutOfBoundsException on Bengli Text

我正在尝试使用 iText7 创建 Bengli 文本的 pdf。 其他文本似乎工作正常,但只有一个。

PdfFont font = null;
try {
     font = PdfFontFactory.createFont("SolaimanLipi.ttf", PdfEncodings.IDENTITY_H);
} catch (IOException e) {
     e.printStackTrace();
}    
Paragraph p = new Paragraph("ওয়ার্ড ২৭").setFont(font).setFontSize(18);
doc.add(p);

我得到的错误:

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at com.itextpdf.layout.renderer.TypographyUtils.callMethod(TypographyUtils.java:252)
    at com.itextpdf.layout.renderer.TypographyUtils.callMethod(TypographyUtils.java:240)
    at com.itextpdf.layout.renderer.TypographyUtils.applyOtfScript(TypographyUtils.java:120)
    at com.itextpdf.layout.renderer.TextRenderer.applyOtf(TextRenderer.java:568)
    at com.itextpdf.layout.renderer.LineRenderer.applyOtf(LineRenderer.java:1146)
    at com.itextpdf.layout.renderer.LineRenderer.layout(LineRenderer.java:143)
    at com.itextpdf.layout.renderer.ParagraphRenderer.layout(ParagraphRenderer.java:205)
    at com.itextpdf.layout.renderer.RootRenderer.addChild(RootRenderer.java:134)
    at com.itextpdf.layout.RootElement.createAndAddRendererSubTree(RootElement.java:377)
    at com.itextpdf.layout.RootElement.add(RootElement.java:106)
    at com.itextpdf.layout.Document.add(Document.java:160)

Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.itextpdf.layout.renderer.TypographyUtils.callMethod(TypographyUtils.java:246)
    ... 36 more
Caused by: java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
    at java.util.ArrayList.rangeCheck(ArrayList.java:657)
    at java.util.ArrayList.get(ArrayList.java:433)
    at com.itextpdf.typography.ordering.indic.IndicCluster.get(IndicCluster.java:69)
    at com.itextpdf.typography.ordering.indic.IndicShaper.finalReordering(IndicShaper.java:901)
    at com.itextpdf.typography.shaping.Shaper.applyIndicScript(Shaper.java:237)
    at com.itextpdf.typography.shaping.Shaper.applyOtfScript(Shaper.java:99)

我正在使用 iText 7.1.2typography 2.0.0。 任何帮助将不胜感激。谢谢

集群 র্য 的其他用户报告了一个非常相似的问题,该问题已得到修复。但是,还没有包含此错误修复的正式版本。

您可以尝试使用最新成功构建的项目进行测试,您可以从 https://repo.itextsupport.com/webapp/#/artifacts/browse/simple/General/snapshot/com/itextpdf/typography/2.0.1-SNAPSHOT

下载

包含此修复的排版模块的下一个正式版本将于 7 月发布。