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 build simple search page using ZK and Spring Boot? - March 8, 2023
- How do I calculate days between two dates excluding weekends and holidays? - January 12, 2023
- How do I discover the quarter of a given date? - January 11, 2023