title: Get list of english fonts only
body: <p>I'm trying to get a list of all english fonts and print some strings with them. </p>
  
  <p>This is the code I use to create the images of the strings: </p>
  
  <pre><code>public static BufferedImage imageForString (String str, Font font) {
  
      font = new Font(font.getName(), font.getStyle(), 400); //Can't trust people to size their own font -_-
  
      BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
      Graphics2D g2d = img.createGraphics();
  
      g2d.setFont(font);
      FontMetrics fm = g2d.getFontMetrics();
      int width = fm.stringWidth(str);
      int height = fm.getHeight();
      g2d.dispose();
  
      try {
          img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
      } catch (Exception e) {
          System.err.println("Problem printing: " + str + " " + "with font: " + font);
          e.printStackTrace();
      }
      g2d = img.createGraphics();
      g2d.setColor(Color.WHITE);
      g2d.fillRect(0, 0, img.getWidth(), img.getHeight());
      g2d.setFont(font);
      fm = g2d.getFontMetrics();
      g2d.setColor(Color.BLACK);
      g2d.drawString(str, 0, fm.getAscent());
      g2d.dispose();
      return img;
  
  }
  </code></pre>
  
  <p>I'm trying to print every letter of the alphabet separately in every font the system has that is capable of displaying english text. That's obviously not working because  I keep getting exceptions thrown on the line I put the try/catch block around.</p>
  
  <p>I'm using this to get a list of all fonts the system has (apparently it includes other languages?):</p>
  
  <pre><code>public static final Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
  </code></pre>
  
  <p>Here's the exception being thrown: </p>
  
  <pre><code>Problem printing: ' with font: java.awt.Font[family=Al Bayan,name=AlBayan,style=plain,size=400]
  java.lang.IllegalArgumentException: Width (0) and height (601) cannot be &lt;= 0
      at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:999)
      at java.awt.image.BufferedImage.&lt;init&gt;(BufferedImage.java:326)
      at HashMaker.imageForString(HashMaker.java:48)
      at HashMaker.getImgs(HashMaker.java:69)
      at HashMaker.main(HashMaker.java:83)
  Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
      at sun.awt.image.IntegerInterleavedRaster.getDataElements(IntegerInterleavedRaster.java:201)
      at java.awt.image.BufferedImage.getRGB(BufferedImage.java:911)
      at ImageUtils.colIsWhite(ImageUtils.java:23)
      at ImageUtils.parseImage(ImageUtils.java:40)
      at Letter.&lt;init&gt;(Letter.java:24)
      at HashMaker.main(HashMaker.java:85)`
  </code></pre>
  
  <p>It's not just the single quote, the exception is also thrown on latin characters such as a 'J' </p>