Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Monospaced Fonts

807603Feb 27 2008
Hi
I have read: http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Font.html

"
Logical fonts are the five font families defined by the Java platform which must be supported by any Java runtime environment: Serif, SansSerif, Monospaced, Dialog, and DialogInput. These logical fonts are not actual font libraries. Instead, the logical font names are mapped to physical fonts by the Java runtime environment. The mapping is implementation and usually locale dependent, so the look and the metrics provided by them vary. Typically, each logical font name maps to several physical fonts in order to cover a large range of characters.
"

I can obtain all the fonts that are in a particular system, but now need to go though them to see if they are Monospaced.
This is what I have done so far:
String[] allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();

ArrayList<String> monoFonts = new ArrayList();
for(int i=0;i<allFonts.length; i++)
{
  if (f.getFamily().toString().equals("Monospaced"))
  {
    monoFonts.add(allFonts);
}
}
Thanks!
Sam                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 26 2008
Added on Feb 27 2008
0 comments
205 views