use custom font java

Solutions on MaxInterview for use custom font java by the best coders in the world

showing results for - "use custom font java"
Niko
21 May 2016
1try {
2  
3    Font font = Font.createFont(Font.TRUETYPE_FONT,
4                                new File("./Fonts/AyyBoyyy.ttf"));
5    Font bold = font.deriveFont(Font.BOLD, 12);
6	Font plain = font.deriveFont(Font.PLAIN, 12);
7  
8} catch (FontFormatException | IOException e) {
9  e.printStackTrace();
10}
Valentín
30 Jul 2019
1try {
2     GraphicsEnvironment ge = 
3         GraphicsEnvironment.getLocalGraphicsEnvironment();
4     ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File("A.ttf")));
5} catch (IOException|FontFormatException e) {
6     //Handle exception
7}
8