Source Code : Getting the Font Faces for a Font Family
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Getting the Font Faces for a Font Family
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Main {
public static void main(String[] argv) throws Exception {
Map<String, List<String>> fontFaceNames = new HashMap<String, List<String>>();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Font[] fonts = ge.getAllFonts();
for (int i = 0; i < fonts.length; i++) {
String familyName = fonts[i].getFamily();
String faceName = fonts[i].getName();
List<String> list = fontFaceNames.get(familyName);
if (list == null) {
list = new ArrayList<String>();
fontFaceNames.put(familyName, list);
}
list.add(faceName);
}
System.out.println(fontFaceNames);
}
}
Thank with us