为什么使用Arial Unicode MS无法正确显示古吉拉特文

编程入门 行业动态 更新时间:2024-10-28 00:17:31
本文介绍了为什么使用Arial Unicode MS无法正确显示古吉拉特文 - 印度文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是关于这个问题的后续处理

$ b不同

હિપ્સ

我用 itextpdf-5.5.4.jar , itextpdf-5.5.9.jar 还有 itext-2.1.7.js3 .jar (与jasper-reports一起发布)

使用MS Office发布的字体 ARIALUNI.TTF ,可以从这里下载 Arial Unicode MS *可能有一些法律问题下载请参阅Mike'Pomax'Kamermans comment

解决方案

iText5和iText2(这是一个非常过时的版本)支持印度语脚本的呈现,无论您选择哪种字体。

呈现印度语脚本与任何拉丁脚本不相似,因为一连串的额外应该采取行动来获得正确的结果,例如一些字符需要根据语言规则先重新排序。

这是iText公司的一个已知问题。

在iText5中存在一个名为GujaratiLigaturizer的古吉拉拉的存根实现,但实现非常糟糕,您不能指望得到正确的结果。

您可以尝试使用这个ligaturizer来处理你的字符串,然后以下面的方式输出结果字符串:

IndicLigaturizer g = new GujaratiLigaturizer(); 字符串处理= g.process(inputString); //继续处理字符串

This is a follow-up on this question How to export fonts in Gujarati-Indian Language to pdf?, @amedee-van-gasse, QA Engineer at iText asked me to post a question specific to itext with relevant mcve.

Why is this sequence of unicode \u0ab9\u0abf\u0aaa\u0acd\u0ab8 not rendered correctly?

It should be rendered like this:

હિપ્સ , also tested with unicode-converter

However this code (example adapted form iText: Chapter 11: Choosing the right font)

public class FontTest { /** The resulting PDF file. */ public static final String RESULT = "fontTest.pdf"; /** the text to render. */ public static final String TEST = "\u0ab9\u0abf\u0aaa\u0acd\u0ab8"; 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( "ARIALUNI.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(); System.out.println("DONE"); } public static void main(String[] args) throws IOException, DocumentException { new FontTest().createPdf(RESULT); } }

Generates this result:

That looks different from

હિપ્સ

I have test with itextpdf-5.5.4.jar,itextpdf-5.5.9.jar and also itext-2.1.7.js3.jar (distributed with jasper-reports)

The font used it the one distributes with MS Office ARIALUNI.TTF and it can be download from here Arial Unicode MS *Maybe there are some legal issues downloading see Mike 'Pomax' Kamermans comment

解决方案

Neither iText5 nor iText2 (which is a very outdated version by the way) support rendering of Indic scripts, no matter which font you select.

Rendering Indic scripts is not similar to any Latin scripts, because a long series of additional actions should be taken to get the correct result, e.g. some characters need to be reordered first according to the language rules.

This is a known issue to iText company.

There is a stub implementation for Gujaranti in iText5 called GujaratiLigaturizer, but the implementation is really poor and you cannot expect to get correct results with it.

You can try to process your string with this ligaturizer and then output the resultant string in the following way:

IndicLigaturizer g = new GujaratiLigaturizer(); String processed = g.process(inputString); // proceed with the processed string

更多推荐

为什么使用Arial Unicode MS无法正确显示古吉拉特文

本文发布于:2023-07-26 18:19:05,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:古吉拉特   正确   Arial   Unicode   MS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!