Attempts to create a font from a filename. Concise error reported if exceptions found. @param filename the name of the font file.
(final String filename)
| 59 | * the name of the font file. |
| 60 | */ |
| 61 | public static Font newFont(final String filename) { |
| 62 | final File file = new File(filename); |
| 63 | Font ttf = null; |
| 64 | |
| 65 | try { |
| 66 | ttf = Font.createFont(Font.TRUETYPE_FONT, file); |
| 67 | } catch (final FontFormatException e) { |
| 68 | System.err.println("GuiUtils > newFont: bad font format \"" + filename + "\""); |
| 69 | } catch (final IOException e) { |
| 70 | System.err.println("GuiUtils > newFont: can't find \"" + filename + "\""); |
| 71 | } |
| 72 | |
| 73 | Lang lang = Lang.initInstance(FModel.getPreferences().getPref(FPref.UI_LANGUAGE)); |
| 74 | if (!ttf.canDisplay(lang.canDisplayCheck())) { |
| 75 | // Use the system default font if can't display the above character |
| 76 | ttf = new JLabel().getFont(); |
| 77 | } |
| 78 | |
| 79 | return ttf; |
| 80 | } |
| 81 | |
| 82 | private static final int minItemWidth = 100; |
| 83 | private static final int itemHeight = 25; |
no test coverage detected