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 34 35 36 37 38
| public class Police {
private final String font = "font/FREEBSC_.ttf";
private final URL ufont = getClass().getResource(font);
private Font policeEcriture25;
private Font policeEcriture18;
private Font policeEcriture14;
private Font policeEcriture12;
public Police(){
try {
URLConnection con;
con = ufont.openConnection();
con.connect();
urlfs = con.getInputStream();
loadFonts();
} catch (IOException ex) {
ex.printStackTrace();
}
}
public void loadFonts() {
try {
String s = Font.createFont(Font.TRUETYPE_FONT, urlfs).getFamily();
policeEcriture25 = new Font(s, Font.BOLD, 24);
policeEcriture18 = new Font(s, Font.BOLD, 18);
policeEcriture14 = new Font(s, Font.BOLD, 14);
policeEcriture12 = new Font(s, Font.BOLD, 12);
} catch (Exception e) {
e.printStackTrace();
System.out.println("exception");
policeEcriture25 = new Font("Serif", Font.BOLD, 25);
policeEcriture18 = new Font("Serif", Font.BOLD, 18);
policeEcriture14 = new Font("Serif", Font.BOLD, 14);
policeEcriture12 = new Font("Serif", Font.BOLD, 12);
}
} |
Partager