MCPcopy Create free account
hub / github.com/Card-Forge/forge / newFont

Method newFont

forge-gui-desktop/src/main/java/forge/gui/GuiUtils.java:61–80  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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;

Callers 1

loadFullMethod · 0.95

Calls 5

initInstanceMethod · 0.95
getPreferencesMethod · 0.95
canDisplayCheckMethod · 0.95
getPrefMethod · 0.45
getFontMethod · 0.45

Tested by

no test coverage detected