问题描述
在
出于好奇,发生了什么? (似乎是某些字符,虚线圆圈应该向后移动,但是这不会发生)。
这是 .tff
的问题还是iText不支持这种字体?
转换(原的问题)开发者评论答案(社区维基)
您看到的行为是由iText 不支持连字这一事实引起的。 (上的当前版本 5.5.8 )
您需要下一个未发布的iText版本。我们将在明年(2016年)发布测试版本,但仅限于客户
感谢关于在iText中直接访问openType字形的其他问题有一个答案
In jasper-reports section there is this jasper-report-character-encoding-in-pdf question.
The problem can not be solved in jasper report since it seems to be an itext problem (using iText v. 5.5.4)
Example code:
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);
}
}
The font can be downloaded at mm3.ttf
Will render incorrectly as:
it should render as (in browser using same ttf
)
Just out of curiosity what is happening? (seems like certain char, with dotted circles should move backwards but this is not happening).
Is this a problem with .tff
or that iText does not support these kind of fonts?
Converting Bruno Lowagie (Original developer of itext) comment into answer (community wiki)
The behavior you see is caused by the fact that iText doesn't support ligatures. (Current version on github.com 5.5.8)
You need one of the next, unreleased versions of iText. We'll release beta versions next year (2016) but only to customers
Thanks to some bounty offered by @Rad Lexus this other question about accessing directly openType glyph in iText has an answer Accessing OpenType glyph variants in iText
这篇关于字体(Myanmar3)在iText中不能正确呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!