Question

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?

Was it helpful?

Solution

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";

OTHER TIPS

1.just convert your kannada text(it will be in ascii) to unicode. [here is the link to convert http://aravindavk.in/ascii2unicode/]

2.copy the unicode text in java file.

String[] v={"ತಾಯಿ","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p"};

  1. save the file in utf-8 then run it will work.

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top