将 JTextArea 字体类型更改为 sinhala

Change JTextArea font type to sinhala

我使用 JTextArea 创建了文本编辑器。但它不适用于 sinhala 字体类型。

t = new JTextArea();
t.setFont(new Font("kaputadotcom2004", Font.PLAIN, 12));

由于 kaputadotcom2004 不是默认字体,您需要注册您的字体才能在您的环境中使用它。你可以做这样的事情(例子取自 answer):

try 
{
     GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
     ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File("A.ttf")));
} 
catch (IOException|FontFormatException e) 
{
     //Handle exception
}