Béatrice Cassistat
Béatrice Cassistat

Reputation: 1078

Displaying special unicode characters in Java/Swing

I wanted to draw special characters like this one ( http://www.fileformat.info/info/unicode/char/2605/index.htm ) in JLabel. It's working great on Mac OS X.

To avoid encoding problem, I've defined this like that :

public static final char STAR = '\u2605';

But on Windows 7, I've got a square representing an unknown character. I've googled and it looks like we need to hand-edit the font configuration files that the JRE uses.

I would like my application to be portable and not requiring this kind of intervention from the user.

Any idea is appreciated. Many thanks !

Upvotes: 1

Views: 2581

Answers (1)

Martin Algesten
Martin Algesten

Reputation: 13620

The problem is most likely that the specific character is not part of the font on the windows platform. This is the case for many higher unicode chars. You need to find one that exists on all platforms.

It's even the case that a typeface called the same on different platforms may have entirely different support of chars. You could try switching the typeface and see if you can find one that has the star consistently across platforms.

Your encoding of the unicode char is completely portable.

Upvotes: 3

Related Questions