Site icon

Print / list all fonts & font family using java (example)

Program – get or list all system fonts & font’s family using java (example)

package org.numbers;


import java.awt.*;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;

public class AvailableFonts {
    public static void main(String[] args) {

        GraphicsEnvironment gEnvironment = GraphicsEnvironment
                                            .getLocalGraphicsEnvironment();
        Font[] fonts = gEnvironment.getAllFonts();

        AtomicInteger atomicInteger = new AtomicInteger(1);
        Arrays.stream(fonts)
                .forEach(font -> {
                    System.out.printf(
                            "%d. Font Family=%s, Font Name=%s \n",
                            atomicInteger.getAndIncrement(),
                            font.getFamily(),
                            font.getFontName());

                });
    }
}

Output – Print all fonts & font’s family using java (example)

1 Font Family=Agency FB, Font Name=Agency FB 
2 Font Family=Agency FB, Font Name=Agency FB Bold 
3 Font Family=Algerian, Font Name=Algerian 
4 Font Family=Arial, Font Name=Arial 
5 Font Family=Arial Black, Font Name=Arial Black 
6 Font Family=Arial, Font Name=Arial Bold 
7 Font Family=Arial, Font Name=Arial Bold Italic 
8 Font Family=Arial, Font Name=Arial Italic 
9 Font Family=Arial Narrow, Font Name=Arial Narrow 
10 Font Family=Arial Narrow, Font Name=Arial Narrow Bold 
11 Font Family=Arial Narrow, Font Name=Arial Narrow Bold Italic 
12 Font Family=Arial Narrow, Font Name=Arial Narrow Italic 
13 Font Family=Arial Rounded MT Bold, Font Name=Arial Rounded MT Bold 
14 Font Family=Baskerville Old Face, Font Name=Baskerville Old Face 
15 Font Family=Bauhaus 93, Font Name=Bauhaus 93 
16 Font Family=Bell MT, Font Name=Bell MT 
17 Font Family=Bell MT, Font Name=Bell MT Bold 
18 Font Family=Bell MT, Font Name=Bell MT Italic 
19 Font Family=Berlin Sans FB, Font Name=Berlin Sans FB 
20 Font Family=Berlin Sans FB, Font Name=Berlin Sans FB Bold 
21 Font Family=Berlin Sans FB Demi, Font Name=Berlin Sans FB Demi Bold 
22 Font Family=Bernard MT Condensed, Font Name=Bernard MT Condensed 
23 Font Family=Blackadder ITC, Font Name=Blackadder ITC 
24 Font Family=Bodoni MT, Font Name=Bodoni MT 
25 Font Family=Bodoni MT Black, Font Name=Bodoni MT Black 
26 Font Family=Bodoni MT Black, Font Name=Bodoni MT Black Italic 
27 Font Family=Bodoni MT, Font Name=Bodoni MT Bold 
28 Font Family=Bodoni MT, Font Name=Bodoni MT Bold Italic 
29 Font Family=Bodoni MT Condensed, Font Name=Bodoni MT Condensed 
30 Font Family=Bodoni MT Condensed, Font Name=Bodoni MT Condensed Bold 
31 Font Family=Bodoni MT Condensed, Font Name=Bodoni MT Condensed Bold Italic 
32 Font Family=Bodoni MT Condensed, Font Name=Bodoni MT Condensed Italic 
33 Font Family=Bodoni MT, Font Name=Bodoni MT Italic 
34 Font Family=Bodoni MT Poster Compressed, Font Name=Bodoni MT Poster Compressed 
35 Font Family=Book Antiqua, Font Name=Book Antiqua 
36 Font Family=Book Antiqua, Font Name=Book Antiqua Bold 
37 Font Family=Book Antiqua, Font Name=Book Antiqua Bold Italic 
38 Font Family=Book Antiqua, Font Name=Book Antiqua Italic 
39 Font Family=Bookman Old Style, Font Name=Bookman Old Style 
40 Font Family=Bookman Old Style, Font Name=Bookman Old Style Bold 
41 Font Family=Bookman Old Style, Font Name=Bookman Old Style Bold Italic 
42 Font Family=Bookman Old Style, Font Name=Bookman Old Style Italic 
43 Font Family=Bookshelf Symbol 7, Font Name=Bookshelf Symbol 7 
44 Font Family=Bradley Hand ITC, Font Name=Bradley Hand ITC 
45 Font Family=Britannic Bold, Font Name=Britannic Bold 
46 Font Family=Broadway, Font Name=Broadway 
47 Font Family=Brush Script MT, Font Name=Brush Script MT Italic 
48 Font Family=Calibri, Font Name=Calibri 
49 Font Family=Calibri, Font Name=Calibri Bold 
50 Font Family=Calibri, Font Name=Calibri Bold Italic 

------Rest of fonts........
Exit mobile version