java - 在 Mac OS X 上的 Java Swing JComponent 中呈现梵文连字 (Unicode)

标签 java macos unicode rendering ligature

我正在尝试在 Mac OS X 10.6 上正确呈现梵文连字(Unicode 字符串)。

字符串绘制在 JComponent 上,并采用 RenderingHints 进行抗锯齿。连字在 Windows XP SP2 和 7 以及 Ubuntu 中正确显示,但在 Mac OS X 中,连字被分解(或者更确切地说,未正确合并),变音符号被移离其位置等(参见下面的屏幕截图,左侧 Win XP SP2 的正确渲染示例(使用 RenderingHints Antialiasing Key ON),右侧 Mac OS X 10.6.7 的错误渲染示例(Antialising 默认 = 关闭)。

我已将字体设置如下,所以它应该在任何系统上使用默认字体:

new Font(null,Font.PLAIN,20);

我相信这一切可能与 Mac 上的默认字符编码是 MacRoman(不是 UTF-8 子集)以及其他系统(如 Windows)使用 UTF-8 子集(如WinLatin-1) 或 cp1252 等。

即使手头有这些信息,我也不知道如何处理这个问题。因此,如果有人能够指出我正确的方向,我将非常感激。

correct and incorrect rendering of the same string

我已经尝试了很多方法:

  • 将字体设置为梵文 MT 并不能解决问题
  • TextAttribute LIGATURES_ON 没有解决问题

我非常感谢其他开发人员(最好具有印地语背景并在 Mac 上开发)提供的任何提示或代码片段。

最佳答案

我自己不是专家,但这里有一些建议。据我从维基百科了解到,问题很可能出在您的字体上。提前为长引用道歉,否则我可以链接 2 篇维基百科文章。

这里是 Unicode article 中关于 连字 部分的一部分:

Ligatures

Many scripts, including Arabic and Devanagari, have special orthographic rules that require certain combinations of letterforms to be combined into special ligature forms. The rules governing ligature formation can be quite complex, requiring special script-shaping technologies such as ACE (Arabic Calligraphic Engine by DecoType in the 1980s and used to generate all the Arabic examples in the printed editions of the Unicode Standard), which became the proof of concept for OpenType (by Adobe and Microsoft), Graphite (by SIL International), or AAT (by Apple).

进一步阅读 AAT (Apple Advanced Typography)文章,揭示了以下信息。我建议阅读整篇文章。

AAT and OpenType in Mac OS X

As of Mac OS X 10.5 Leopard, partial support for OpenType is available. The support is currently limited to Western scripts and Arabic (as of 2011). If a font has AAT tables, they will be used for typography. If the font does not have AAT tables but does have OpenType tables, they will be used to the extent that the system supports them.

This means that many OpenType fonts for Western or Middle Eastern scripts can be used without modification on Mac OS X 10.5, but South Asian scripts such as Thai and Devanagari cannot. These require AAT tables for proper layout.

稍后在关于字体布局的部分:

Since AAT operates entirely with glyphs and never with characters, all the layout information necessary for producing the proper display resides within the font itself. This allows fonts to be added for new scripts without requiring any specific support from the OS.

最后:

AAT for Indic scripts

For Indic scripts, the only features that are necessary are glyph re-ordering and substitution. AAT supports both of these. As noted above, OpenType fonts for Indic scripts require AAT tables to be added before they will function properly on Mac OS X. Note, however, that this applies only to software dependent upon the system support of OpenType. Programs which provide their own implementation of OpenType will render Indic properly with OpenType fonts. (They may, however, not render Indic fonts with AAT tables correctly.)

Mac OS X 10.5 ships with fonts for Devanagari, Gurmukhi, Gujarati, Thai, Tibetan, and Tamil. Fonts for other Indic scripts are available from third parties.

也许你需要选择一种明确支持梵文的字体。

关于java - 在 Mac OS X 上的 Java Swing JComponent 中呈现梵文连字 (Unicode),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5994815/

相关文章:

java - 设置android记事本教程项目时丢失文件

python - PyCrypto 和 GMP 库未找到错误 [Mac OS 10.6.3]

java - java中的Unicode调用

PostgreSQL - 替换表列中特定字符的所有实例

java - 如何渲染不同尺寸的图 block ?

java - 由于基础异常 : 'java.lang.NumberFormatException: For input string: "localhost:330 6"' ,无法加载连接类

swift - 沙盒时无法终止其他应用程序

html - Word XML - XSLT 到 HTML

java - 在网页中嵌入仅查看 Word 文档

c - 为什么这个程序无法在终端中输出这些字符串?