<AWT Dev> font attributes

Alan Snyder javalists at cbfiddle.com
Thu Dec 21 18:49:38 UTC 2017


If I run the following code (on macOS), I get no useful information.

Font[] fonts = ge.getAllFonts();
for (Font f : fonts) {
 String family = f.getFamily();
 if ("Lato".equals(family)) {
  Map<TextAttribute,?> attributeMap = f.getAttributes();
  Object o = attributeMap.get(TextAttribute.WEIGHT);
  System.err.println(f.getFontName() + ": " + o);
 }
}
The only attributes with non-null values are the family (which is wrong, it is the font name, e.g. Lato-Black) and the size (which is 1, as expected).

I know that other information is available, but is there a way to get it using public APIs?

If not, why not?

  Alan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/awt-dev/attachments/20171221/77a210f1/attachment.html>


More information about the awt-dev mailing list