11

I have a JTextArea where I need to show Bengali text like:

বাংলাদেশ

But all I can see is rectangular boxes. How can I show Bengali characters properly?

Mechanical snail
  • 29,755
  • 14
  • 88
  • 113

1 Answers1

15

First take a bangla unicode supported font like:

Font banglaFont=new Font("Arial Unicode MS", Font.BOLD,15);

Then attach it to your JTextArea object using setFont

text1.setFont(banglaFont);

Now you should be able to view bangla properly, give a try.

NOTE: Java uses font from the system , so if the system doesn't contain a specific font then you can deploy that font within your application using Font.createFont().

Imran Rana
  • 11,899
  • 7
  • 45
  • 51
  • 3
    Arial Unicode MS is just an example, you can use any custom font with Bangla support. – Imran Rana Apr 28 '12 at 12:26
  • 2
    @Imran Rana please you forgot to answering (@ Andrew Thompson) question about Font supports on *nix and apple OSX – mKorbel Apr 28 '12 at 12:50
  • 3
    @AndrewThompson Java uses font from the system , so if the system doesn't contain a specific font then you can deploy that font within your application using Font.createFont(). – Imran Rana Apr 28 '12 at 17:47
  • *"you can deploy that font within your application.."* It might be a good idea to mention that in the answer, since any font ending in MS would not typically be installed on an OS X or *nix machine. ;) – Andrew Thompson Apr 28 '12 at 19:25
  • *"so if the system doesn't contain a specific font then you can deploy that font within your application"* Presuming you have the right to distribute that font at all. Which, in the case of an MS font, I can almost guarantee you don't. – Andrew Thompson Apr 26 '16 at 01:49