I have a problem with displaying unicode characters in my swing application.
In think the problem is the used font, which does not contain appropriate characters for chinese language.
(only empty boxes are displayed)
Here are some more infos to my Problem (i did some investigation):
Linux (Kubuntu 14.04):
When i start my program with JAVA 6, chinese characters are not displayed (only empty boxes).
(asking the labels font via getFont() returns: DejaVu Sans)
When i start my program with JAVA 7, chinese characters are displayed correctly!
(asking the labels font via getFont() returns: DejaVu Sans)
Windows (8.1):
When i start my program with JAVA 6, chinese characters are displayed correctly!
(asking the labels font via getFont() returns: SansSerif)
When i start my program with JAVA 7, chinese characters are displayed correctly!
(asking the labels font via getFont() returns: SansSerif)
$JAVA_HOME/lib/fonts, (which seems to be used as fallback-font) both java versions (6+7) contain the same fonts. (on both systems)
The font files have same size (Java6 + Java7) and fontconfig.properties.src are also both the same.
When i am asking directly the Label (via getFont()) it returns "SansSerif" on Windows(8.1) and "DejaVu Sans" on my Kubuntu(14.04).
(see the screenshots)
Started on Linux with JAVA 6:
Started on Linux with JAVA 7:
"SansSerif" on Windows is showing the characters correctly, but which SansSerif-Font is used? MS SansSerif (the only Font with SansSerif in name) does not have all of this chinese characters.
EDIT:
Same with DejaVuSans.
It looks like DejaVu Sans does not have chinese characters! (however, they are displayed!)
EDIT 2:
i tried the code Andrew posted (see: How to determine if 2 fonts have equivalent glyphs?), but with chinese example Text
this is the result:
Started on Linux with JAVA 6:
Started on Linux with JAVA 7:
EDIT 3:
as reqested, here the String which i have tested:
String s = "\u6253\u5370\u8FC7\u671F\u8BC1\u4E66\u8BB0\u5F55"; //means: 打印过期证书记录
JOptionPane.showMessageDialog(null, s);
Question is:
Which font (on the system) is really used and how can i find out?
Thanks in advance!