how to load font in java

Solutions on MaxInterview for how to load font in java by the best coders in the world

showing results for - "how to load font in java"
Luka
17 Apr 2019
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}
Katelynn
05 Jul 2016
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