3 import java.awt.Canvas;
5 import java.awt.FontMetrics;
9 public class FontChooserTest
13 * Not a real test as it runs no methods on FontChooser and makes no
14 * assertions, but this method writes to sysout the names of any (currently
15 * available, plain) fonts and point sizes that would be rejected by Jalview's
16 * FontChooser as having an I-width of less than 1.0.
19 public void dumpInvalidFonts()
21 String[] fonts = java.awt.GraphicsEnvironment
22 .getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
23 for (int pointSize = 1;; pointSize++)
25 System.out.println(System.lineSeparator()
26 + "Fonts with insufficient width at " + pointSize + "pt:");
29 System.out.println("All except:");
32 for (String fontname : fonts)
34 Font newFont = new Font(fontname, Font.PLAIN, pointSize);
35 FontMetrics fontm = new Canvas().getFontMetrics(newFont);
36 double iw = fontm.getStringBounds("I", null).getWidth();
37 final boolean tooSmall = iw < 1d;
42 if ((pointSize > 1 && tooSmall) || (pointSize == 1 && !tooSmall))
44 System.out.println(fontname);