In Java we can create a Font object as such:
new Font("Helvetica", Font.PLAIN, 12);
My question is how do we get the entire list of font names from Java, for example "Helvetica" which we can use it as one the argument for the Font constructor?
I tried the following, but I can't find "Helvetica" in all of the lists.
GraphicsEnvironment ge;
ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] names = ge.getAvailableFontFamilyNames();
Font[] allFonts = ge.getAllFonts();
for(int x=0; x<names.length; x++)
System.out.println(names[x]);
for(int x=0; x<allFonts.length; x++){
System.out.println(allFonts[x].getName());
System.out.println(allFonts[x].getFontName());
System.out.println(allFonts[x].getFamily());
System.out.println(allFonts[x].getPSName());
}
Edit: More importantly, I also want to know what is the first attribute call in Font constructornew Font("What attribute is this?", Font.PLAIN, 12)
Q: Is it a fontName, family, fontFace, name or what?
Helivetica
word. – Nonalcoholicname
is it referring to. Can I assume thename
mentioned in the API is same as what I can receive fromallFonts[x].getName()
? – Figone