如何使 JTextField 呈现补充字符 [英] How to make JTextField render supplementary characters

查看:66
本文介绍了如何使 JTextField 呈现补充字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试设置一些 JTextComponent 小部件(主要是 JTextField 组件)以输入 Unicode 文本.在此,我需要渲染僧伽罗字符.我在所有
中设置了 Iskoola Pota 字体这在大多数情况下都可以正常工作,但在某些时候会失败.

具有一两个字符的字符正确呈现.

例如:අම්මා, වයඹ, අධිකාරිය

但是问题出在 3 个字符的字符上.

例如:ප්‍රවෘත්ති(这被渲染为ප්රවෘත්ති)ව්‍යාපෘතිය(这被渲染为ව්යාපෘතිය)

问题是诸如ප්‍ර的字符被渲染为(ප්ර)ව්‍යා被渲染为(ව්යා).下面提供了屏幕截图.

图片在这里:http://i.stack.imgur.com/bQrQB.png在这里,අම්මා, වයඹ, අධිකාරිය 正确呈现,但ප්‍රවෘත්ති和භභතිභභඁ්ඁ්ඁ

我也更新了我的 JDK 版本和 JRE.这是 NetBeans IDE 中显示的版本详细信息.

Java:1.7.0_40;Java HotSpot(TM) 客户端 VM 24.0-b56运行时:Java(TM) SE 运行时环境 1.7.0_40-b43系统:运行在x86上的Windows 7 6.1版;cp1252;en_US (nb)

我无法理解如何在我的程序中实现补充字符和代理对 API jsr204.非常感谢任何形式的帮助.提前致谢.

解决方案

尝试了解 layoutGlyphVector 如何处理三重字符.它是否提供了正确的表示?如果是,您可以尝试按照此处所述设置自定义 GlyphPainter http://java-sl.com/Scale_In_JEditorPane_GlyphPainter.html

I tried to set some JTextComponent widgets (mostly JTextField components) to enter text in Unicode. In this, I need to render Sinhala characters. I set Iskoola Pota font in all my
This works fine most of the time but fails at some points.

characters with one or two characters render correctly.

Ex: අම්මා, වයඹ, අධිකාරිය

But the problem comes with characters with 3 characters.

Ex: ප්‍රවෘත්ති (THIS IS RENDERED AS ප්රවෘත්ති)
ව්‍යාපෘතිය (THIS IS RENDERED AS ව්යාපෘතිය)

The matter is characters such as ප්‍ර is rendered as (ප්ර) and ව්‍යා is rendered as (ව්යා). Screenshot is provided below.

Image is here : http://i.stack.imgur.com/bQrQB.png Here, අම්මා, වයඹ, අධිකාරිය is rendered properly but ප්‍රවෘත්ති and ව්‍යාපෘතිය words render incorrectly.

I have updated my JDK version and JRE also. Here is the version details as shown in NetBeans IDE.

Java: 1.7.0_40; Java HotSpot(TM) Client VM 24.0-b56
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b43
System: Windows 7 version 6.1 running on x86; Cp1252; en_US (nb)

I cannot understand how to implement the supplementary characters and surrogate pair API jsr204 in my program. Any kind of help is very much appreciated. Thank you in advance.

解决方案

Try to see how layoutGlyphVector works with the triple chars. Does it provide correct representation? If yes you can try to set custom GlyphPainter as described here http://java-sl.com/Scale_In_JEditorPane_GlyphPainter.html

这篇关于如何使 JTextField 呈现补充字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆