Terai Atsuhiro 2023-06-16 (金) 08:17:14

http://terai.s55.xrea.com/swing/createfont/screenshot.png

private static Font makeFont(String rpath) {
  Font font = null;
  InputStream is = null;
  try {
    is = MyCellRenderer.class.getResourceAsStream(rpath);
    font = (Font.createFont(Font.TRUETYPE_FONT, is)).deriveFont(12.0f);
    is.close();
  }catch(IOException ioe) {
    ioe.printStackTrace();
    throw new InternalError(ioe.getMessage());
  }catch(FontFormatException ffe) {
    ffe.printStackTrace();
    throw new InternalError(ffe.getMessage());
  }finally{
    if(is!=null) {
      try {
        is.close();
      }catch(IOException ioex) {
        ioex.printStackTrace();
        throw new InternalError(ioex.getMessage());
      }
    }
  }
  return font;
}