How to Display UTF-8 Characters in SWT? [message #509686] |
Sun, 24 January 2010 13:24  |
Eclipse User |
|
|
|
Is it possible to display UTF-8 characters in SWT?
I tried
Text text = new Text( shell, SWT.BORDER );
Font font = new Font( display, "UTF-8", 20, SWT.NORMAL );
text.setFont( font );
String s = "\u8118";
text.setText( s );
but it doesn't work.
[Updated on: Sun, 24 January 2010 13:25] by Moderator
|
|
|
|
|
|
|
|
Re: How to Displaying UTF-8 Characters in SWT? [message #510050 is a reply to message #509920] |
Tue, 26 January 2010 06:03   |
Eclipse User |
|
|
|
Paul Webster wrote:
> babspam@hotmail.de wrote:
>> The goal was to display classical greek letters, wich utf-8 code
>> position is 1F00 to 1FFF (sorry, 8118 was wrong, it's decimal). This
>> letters are part of the UTF-8 encoding. I don't want special fonts if
>> possible.
>
> As Ed mentions, UTF specifies characters ... think ascii 65 == 'A' but
> says nothing about how 'A' should be displayed (Courier, Times Roman,
> etc) in your terminal or UI. Your font will. You need to make sure
> that your app defaults to a common font that can display characters in
> that range.
>
> PW
>
Try:
for (FontData fontData : display.getFontList(null, false)) {
System.out.println(fontData.getName());
}
for (FontData fontData : display.getFontList(null, true)) {
System.out.println(fontData.getName());
}
this should give you the list of fonts alredy installed in your system.
then you'll have to try which one displays correctly like this:
Font font = new Font( display, fontData.getName(), 20, SWT.NORMAL );
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.09041 seconds