From 1c8fb19eb35a78bc05aba10a2ff631dfac22ed31 Mon Sep 17 00:00:00 2001 From: Brent <90901032@westernsydney.edu.au> Date: Thu, 7 Sep 2023 12:00:29 +1000 Subject: [PATCH] Chasing bug --- .../VASSAL/build/module/font/VassalFont.java | 2 +- .../BeanShellExpressionConfigurer.java | 33 ++++++++----------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/vassal-app/src/main/java/VASSAL/build/module/font/VassalFont.java b/vassal-app/src/main/java/VASSAL/build/module/font/VassalFont.java index b99ac3ff90..268d9f4295 100644 --- a/vassal-app/src/main/java/VASSAL/build/module/font/VassalFont.java +++ b/vassal-app/src/main/java/VASSAL/build/module/font/VassalFont.java @@ -83,7 +83,7 @@ public VassalFont(String fontFileName) { final String fileName = "/fonts/JetBrainsMono.ttf"; logger.warn("Build URL for mono, classloader = " + getClass().getClassLoader()); url = getClass().getResource(fileName); - logger.warn("URL built"); + logger.warn("URL built=" + url); Font.createFont(Font.TRUETYPE_FONT, url.openStream()); logger.warn("Font built"); } diff --git a/vassal-app/src/main/java/VASSAL/configure/BeanShellExpressionConfigurer.java b/vassal-app/src/main/java/VASSAL/configure/BeanShellExpressionConfigurer.java index c576ce5620..692547c467 100644 --- a/vassal-app/src/main/java/VASSAL/configure/BeanShellExpressionConfigurer.java +++ b/vassal-app/src/main/java/VASSAL/configure/BeanShellExpressionConfigurer.java @@ -17,7 +17,6 @@ */ package VASSAL.configure; -import VASSAL.build.GameModule; import VASSAL.counters.EditablePiece; import VASSAL.counters.GamePiece; import VASSAL.i18n.Resources; @@ -207,7 +206,6 @@ protected Component getTopLevelAncestor() { @Override public Component getControls() { if (p == null) { - // expressionPanel = new JPanel(new MigLayout("fillx,ins 0", "[][grow][][]")); //NON-NLS expressionPanel = new ConfigurerPanel(getName(), "[grow,fill]", "[][grow,fill]", "[grow, fill]"); // NON-NLS ((MigLayout) expressionPanel.getLayout()).setLayoutConstraints("ins 0,fill"); @@ -216,7 +214,7 @@ public Component getControls() { validator = new Validator(); nameField = new JTextArea(1, 100); - nameField.setFont(GameModule.getGameModule().getFontOrganizer().getEditorFont(Font.PLAIN, 14)); + nameField.setFont(getEditorFont(Font.PLAIN, 14)); nameField.setLineWrap(true); nameField.setWrapStyleWord(true); nameField.setBorder(BorderFactory.createLineBorder(Color.gray)); @@ -225,22 +223,6 @@ public Component getControls() { nameField.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null); nameField.setText(getValueString()); - - - try { - final String fileName = "/fonts/JetBrainsMono.ttf"; - - logger.warn("Build URL for mono, classloader = " + getClass().getClassLoader()); - final URL url = getClass().getResource(fileName); - logger.warn("URL built"); - final Font ms = Font.createFont(Font.TRUETYPE_FONT, url.openStream()); - logger.warn("Font built"); - nameField.setFont(ms.deriveFont(Font.PLAIN, 14)); - } - catch (Exception e) { - logger.warn("Mono load exception: " + e.getMessage()); - } - panel.add(nameField, "grow"); //NON-NLS nameField.addKeyListener(new KeyAdapter() { @Override @@ -345,6 +327,19 @@ protected void updateParentBuilder() { } } + protected Font getEditorFont(int style, int size) { + try { + final String fileName = "/fonts/JetBrainsMono.ttf"; + final URL url = getClass().getResource(fileName); + logger.warn("URL=" + url); + final Font ms = Font.createFont(Font.TRUETYPE_FONT, url.openStream()); + return ms.deriveFont(style, size); + } + catch (Exception ignored) { + } + return new Font("monospaced", style, size); + } + protected void doPopup() { final JPopupMenu popup = new BeanShellFunctionMenu(target, this); popup.show(extraDetails, 0, 0);