
Original text : තමා_PRP හයිටිය_NNPI අතහැර_VNF පලා_VNF ගියේ_VP කැමැත්තකින්
The reason for this is that, it does not render Sinhala fonts.It is not a problem with detection of encoding. You can simply check the system default encoding with code below.
System.out.println(System.getProperty("file.encoding"));This produced with UTF-8 encoding, which was ok for my requirement.
Now this meant, that the problem is in using an appropriate font for the JTextArea.
File fontFile = new File(fontpath); //load the font file Font newFont = Font.createFont(Font.TRUETYPE_FONT, fontFile); txtOutput.setFont(newFont); //set the font to JTextArea
The above code will add a font to a JTextArea. Out of the many fonts I tried, only "dinamina.ttf" rendered properly. Even lklug did not provide proper results (It only rendered Sinhala and English characters were not at all displayed). Following is the final output.

Download sinhala fonts from here
Updates :
No comments:
Post a Comment