4

I have a simple swing application. When i set a thai text to a JLabel or other components they shows question mark like characters instead of thai text.

Is there anything to do to support thai language in swing applications?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • Can we post some code so i can understand what error you getting here. – Janny Jul 20 '15 at 11:48
  • My code is a little bit complicated, so i don't have a short and nice code. I will try to write a sample to test. And i will paste it here. –  Jul 20 '15 at 11:57

1 Answers1

1

There is not a special function or configuration to do. Be sure that your font supports thai characters.

When i met same problem, component font was set to calibri. After changing it to sansserif it worked.

But i don't know any other font that supports thai, i just found it with brute force tries.

bahtiyartan
  • 1,010
  • 10
  • 29
  • My font is arial, when i change it to SansSerif it shows thai text. It seems arial also does not support thai, so i must find correct font for thai release. –  Jul 20 '15 at 12:26
  • 1
    See [`Font.canDisplayUpTo(String)`](https://docs.oracle.com/javase/8/docs/api/java/awt/Font.html#canDisplayUpTo-java.lang.String-) & [`Font.canDisplay(char)`](https://docs.oracle.com/javase/8/docs/api/java/awt/Font.html#canDisplay-char-) & overloaded variants. See also [UGlys](https://drive.google.com/open?id=0B5B9wDXIGw9leE1VYURuU1ZkZkk) (Unicode Glyphs) an app. I wrote that uses the 2nd variant extensively. – Andrew Thompson Jul 20 '15 at 12:26
  • 1
    See also the code of an [earlier variant of UGlys](http://stackoverflow.com/a/18858313/418556), as well as [this example](http://stackoverflow.com/q/19467137/418556) & [this (rather cute, IMO) example](http://stackoverflow.com/a/30421683/418556).. – Andrew Thompson Jul 20 '15 at 12:30
  • 1
    Oh, and I almost forgot. `SANS_SERIF` is a *logical font* that takes it's character glyphs from a number of other fonts like other logical fonts. It might use Arial for part of the range of code points (and probably would on Windows), while Segoe UI Symbol for other ranges of code points and still more specialized fonts for other languages. OTOH each 'physical font' like Arial will only display the glyphs that it was designed for.. – Andrew Thompson Jul 20 '15 at 12:36