private void registerFont(String name) { if (isHeadlessEnvironment()) return; InputStream is = null; try { is = getClass().getResourceAsStream(name); final Font font = Font.createFont(Font.TRUETYPE_FONT, is); GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(font); } catch (Exception e) { LOG.info(e); } finally { if (is != null) { try { is.close(); } catch (IOException e) { LOG.error(e); } } } }
protected static boolean isInHeadlessEnvironment() { return GraphicsEnvironment.isHeadless(); }
public static boolean isHeadlessEnv() { Application app = ApplicationManager.getApplication(); if (app == null) return GraphicsEnvironment.isHeadless(); return app.isUnitTestMode() || app.isHeadlessEnvironment(); }