Saad Attieh
Saad Attieh

Reputation: 1486

Unicode characters not displaying when Java program run on Windows

Is there any reason why unicode characters are not appearing when my Java program is run on someone else's laptop (Windows)?

I have written a Chess program in Java (Swing) on my Mac. Each piece is represented by a unicode character of that Chess piece. The board is shown as a grid of buttons each of which has its text set to a Chess unicode character.

On my Mac it works fine but my friend (using windows) says that although the grid of buttons appear he cannot see any Chess characters. Luckily I set each buttons' tooltip to be the name of the piece it is representing and this allowed him to test the game however as I'm sure you understand having to hover your mouse above every square just to know what is there is time consuming. Despite this it did show that my program was working fine just was not displaying any unicode.

What can I do to my program or my friends settings on his laptop to resolve this?

Upvotes: 2

Views: 1158

Answers (1)

trashgod
trashgod

Reputation: 205785

This variation on this example works correctly on Windows 7 using the default Font for the family Font.SANS_SERIF, which contains the required glyphs.

static Font font = new Font(Font.SANS_SERIF, Font.PLAIN, 72);

enter image description here

In contrast, you've set the name to null; as a result, "the logical font name of the new Font as returned by getName() is set to the name Default."

Upvotes: 2

Related Questions