package org.kodejava.awt;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
public class FontNameList {
public static void main(String[] args) {
// Get all available fonts from GraphicsEnvironment
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Font[] fonts = ge.getAllFonts();
// Iterates all available fonts and get their name and family name
for (Font font : fonts) {
String fontName = font.getName();
String familyName = font.getFamily();
System.out.println("Font: " + fontName + "; family: " + familyName);
}
}
}
Here are some fonts name printed from the code snippet above:
Font: Agency FB; family: Agency FB
Font: Agency FB Bold; family: Agency FB
Font: Algerian; family: Algerian
Font: Arial; family: Arial
Font: Arial Black; family: Arial Black
Font: Arial Bold; family: Arial
Font: Arial Bold Italic; family: Arial
Font: Arial Italic; family: Arial
Font: Arial Narrow; family: Arial Narrow
Font: Arial Narrow Bold; family: Arial Narrow
...
Latest posts by Wayan (see all)
- How do I create a string of repeated characters? - September 1, 2023
- How do I convert datetime string with optional part to a date object? - August 28, 2023
- How do I split large excel file into multiple smaller files? - April 15, 2023