In Java, we can create a Font object as such:
new Font("Helvetica", Font.PLAIN, 12);
My question is: how to get the whole list of font names from Java, for example "Helvetica", which we can use as an argument for the Font constructor?
I tried the following, but can not find "Helvetica" in all 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 the new Font("What attribute is this?", Font.PLAIN, 12) font constructor new Font("What attribute is this?", Font.PLAIN, 12)
Q: Is it a font name, family name, fontFace, name or what?
source share