-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFontLoader.java
33 lines (27 loc) · 1.04 KB
/
FontLoader.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.awt.Font;
import java.awt.FontFormatException;
import java.io.IOException;
import java.io.InputStream;
public class FontLoader {
// Class: FontLoader
public static Font loadFont(String path, float size) {
// Method: loadFont
// Parameters: String path, float size
try {
InputStream is = FontLoader.class.getResourceAsStream(path);
// Object: InputStream
// Method calling: FontLoader.class.getResourceAsStream(path)
Font font = Font.createFont(Font.TRUETYPE_FONT, is);
// Object: Font
// Method calling: Font.createFont(Font.TRUETYPE_FONT, is)
return font.deriveFont(size);
// Method calling: font.deriveFont(size)
} catch (FontFormatException | IOException e) {
e.printStackTrace();
// Method calling: e.printStackTrace()
return new Font("Arial", Font.PLAIN, 14);
// Object: Font
// Method calling: new Font("Arial", Font.PLAIN, 14)
}
}
}