tags:

views:

133

answers:

1

I am trying to dislplay a kannda character in a Java app.

String fonts[] = ge.getAvailableFontFamilyNames();

This shows that there is a font family by name "BRH Kannada"

Font f = new Font("BRH Kannada", Font.PLAIN, 20);

and then I do

button.setFont(f);

now when i set the button text, I have to ideally get the text on button to use the BRH kannada font.

However, what and how should I give the string as?

A: 

Let us assume that you are trying to create a Java string literal containing kannada characters:

  • If you have a text editor / IDE and Java compiler that is capable of handling UTF-8 files, you can simply put kannada characters into the string:

    String buttonText = "ಅಈಧ";

  • If you want your source files to be editable / compilable with a tool chain that is not UTF-8 capable, you can express the kannada characters as Unicode escapes; i.e. \uxxxx where xxxx are 4 hex digits.

    String buttonText = "\u0c85\u0c88\u0ca7";

Stephen C