Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Locale Font question..?

Tags:

java

fonts

locale

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

like image 467
Andy Schmidt Avatar asked Sep 15 '25 17:09

Andy Schmidt


1 Answers

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?

like image 90
OscarRyz Avatar answered Sep 18 '25 09:09

OscarRyz