Suppose a font Kalpurush.ttf (you may find this font here). As it is an Assamese Font and may not have installed in everyone's computer, so, I've embedded this font in my website. It displays fine in any browser, (except android webview. I do not have any headache about android). In fact I've never found any Assamese font to be so nice.
Now I've tried this same font in a Java Swing Application. I've written this class:
public class AssameseFont {
public AssameseFont(){}
public Font Assamese(){
File file = new File("kalpurush.ttf");
Font as = null;
try{
FileInputStream input = new FileInputStream(file);
as = Font.createFont(Font.TRUETYPE_FONT, file);
as = as.deriveFont(Font.PLAIN, 18);
GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(as);
}
catch(FontFormatException | IOException e){
JOptionPane.showMessageDialog(null, ""+e);
}
return as;
}
}
I use to call this in my components using setFont()
method.
But some of my texts does not display as it should be. Why does it happen? Is it a font problem? Or am I doing anything wrong in my java code?