It works with any font. But, it’s hard to use it with proportional fonts because it doesn’t save the dimension information for the characters.
If anyone’s interested, here’s a modified PreviewPanel::save method which writes another file called “metrics.ftx” containing the x/y/width/height of the bounding box for all the characters it puts in the .png image.
public void save(File file, String fmt) throws IOException {
BufferedImage buf = new BufferedImage(sideLength, sideLength, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = (Graphics2D) buf.getGraphics();
drawCharacters(g, Color.white);
ImageIO.write(buf, fmt, file);
DataOutputStream dos = new DataOutputStream(new FileOutputStream(new File(file.getParent(), "metrics.ftx")));
for (char ch = MIN_CH; ch <= MAX_CH; ch++) {
TextLayout layout = new TextLayout(String.valueOf(ch), font,
g.getFontRenderContext());
Rectangle2D rect = layout.getBounds();
float cx = (float) rect.getX();
float cy = boxSize - g.getFontMetrics().getDescent();
dos.writeFloat(cx);
dos.writeFloat(cy);
dos.writeFloat((float) rect.getWidth());
dos.writeFloat((float) rect.getHeight());
}
dos.close();
g.dispose();
}