private static void initFont(String fontName){
  GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
  boolean needsLoading=true;
  for (  String font : ge.getAvailableFontFamilyNames()) {
    if (fontName.equals(font)) {
      needsLoading=false;
      break;
    }
  }
  if (needsLoading) {
    String resource="data/gui/" + fontName + ".ttf";
    try {
      ge.registerFont(Font.createFont(Font.TRUETYPE_FONT,DataLoader.getResourceAsStream(resource)));
    }
 catch (    IOException|FontFormatException e) {
      logger.error("Error loading custom font '" + resource + '"',e);
    }
  }
}

private static void initFont ( String fontName ) { GraphicsEnvironment ge = GraphicsEnvironment . getLocalGraphicsEnvironment ( ) ; boolean needsLoading = true ; for ( String font : ge . getAvailableFontFamilyNames ( ) ) { if ( fontName . equals ( font ) ) { needsLoading = false ; break ; } } if ( needsLoading ) { String resource = "data/gui/" + fontName + ".ttf" ; try { ge . registerFont ( Font . createFont ( Font . TRUETYPE_FONT , DataLoader . getResourceAsStream ( resource ) ) ) ; } catch ( IOException | FontFormatException e ) { logger . error ( "Error loading custom font '" + resource + '"' , e ) ; } } }
load a custom font .
