FontInfo (String name, Font font) { boolean plainOnly = name == null; try { if (font == null) { font = new Font(name, Font.PLAIN, DEFAULT_SIZE); // Java uses Dialog family for nonexistent fonts if (!Font.DIALOG.equals(name) && StartupUiUtil.isDialogFont(font)) { throw new IllegalArgumentException("not supported " + font); } } else if ((float)DEFAULT_SIZE != font.getSize2D()) { font = font.deriveFont((float)DEFAULT_SIZE); name = font.getFontName(ENGLISH); } boolean monospaced = plainOnly ? isMonospaced(font) : isMonospacedWithStyles(font); return new FontInfo(name, font, monospaced); } catch (Throwable ignored) { return null; // skip font that cannot be processed } }