I have downloaded akshar.ttf file and want to add it to my java project. I have tried the following ways by searching online but nothing worked so far.
Try 1:
Font ttfBase = null;
Font ttfReal = null;
try {
InputStream myStream = new BufferedInputStream(new FileInputStream("akshar.TTF"));
ttfBase = Font.createFont(Font.TRUETYPE_FONT, myStream);
ttfReal = ttfBase.deriveFont(Font.PLAIN, 24);
} catch (Exception ex) {
ex.printStackTrace();
System.err.println("akshar font not loaded.");
}
Try 2:
Font font = new Font("akshar",Font.PLAIN,15);
I have the akshar.ttf file at the following places:-
- java/jre/lib/fonts
- bin folder of my project
- src folder of my project
I am new to java and have tried all these by following various links online. Please help me where am i going wrong.