tags:

views:

267

answers:

2

[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:

  1. would the JTextFields show japanese Symbols without me setting this Font?

  2. 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?

  3. do you have any other suggestions?

Thank you for your help!

+2  A: 

For this very reason, my internationalized application sets its font depending on the locale. To answer your questions:

  1. 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."

  2. 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.

  3. Other suggestions: Set your font depending on Locale, at least for select Locales.

Eddie
this happend on OSX with Java 1.5! (but may also happen on Windows).
Andy Schmidt
In BabelMap - what is the Unicode Block Name corresponding to Japanese Symbols?
Andy Schmidt
Katakana is probably the Unicode block you want.
Eddie
I almost guessed. It seems Lucida Sans does not support it or any other block. Or am I wrong?
Andy Schmidt
On this WinXP Pro box, Lucida Sans has many blocks, but it does not have Katakana. It does, for example, have Cyrillic.
Eddie
So I guess if Cyrillic is supported by WinXP's Luicida this does not mean OSX's Luicida also supports it?
Andy Schmidt
The font on each OS is potentially created by a different group of people and may or may not cover the same set of glyphs.
Eddie
+2  A: 

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?

OscarRyz
sorry, no link.
Andy Schmidt