Reputation: 261
[EDIT] this happend on OSX with Java 1.5! (but may also happen on Windows!)
It seems japanese users of my Java Swing program cannot write japanese symbols in JTextFields. Actually they can write them but do not see them. They only see blocks which somehow indicates I think that the font does not support these symbols.
I set my own font for various reasons ("Lucida Sans", Font.PLAIN, 12) - which I wouldn't like to change. My questions are:
would the JTextFields show japanese Symbols without me setting this Font?
could I detect which Locale's are fully supported by my Font and only set it in those cases but leave the standard Java font for all other cases like Locale.Japan?
do you have any other suggestions?
Thank you for your help!
Upvotes: 4
Views: 1234
Reputation: 199215
would the JTextFields show japanese Symbols without me setting this Font?
Most likely since the JRE will choose the default.
could I detect which Locale's are fully supported by my Font and only set it in those cases but leave the standard Java font for all other cases like Locale.Japan?
Yes, in theory, although easier would be to test if this font can display a locale specific character using the the canDisplay(char) method in Font. If it don't, you may switch to the default.
do you have any other suggestions?
Here's a link on this topic that may help
Do you have a link for your product?
Upvotes: 4
Reputation: 54421
For this very reason, my internationalized application sets its font depending on the locale. To answer your questions:
This probably depends on which version of Windows is being used. Is this the US edition with Japanese fonts installed, or is this the version sold in Japan? I don't know the exact answer to your question, but I expect that the answer is, "It depends."
I don't know of any standard way to do this. I have found a wonderful utility for investigating this kind of thing: BabelMap. This will tell you exactly what characters are supported by any given font.
Other suggestions: Set your font depending on Locale, at least for select Locales.
Upvotes: 2