Skip to content

Commit

Permalink
Chasing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Brent committed Sep 7, 2023
1 parent 276b3e0 commit 1c8fb19
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package VASSAL.configure;

import VASSAL.build.GameModule;
import VASSAL.counters.EditablePiece;
import VASSAL.counters.GamePiece;
import VASSAL.i18n.Resources;
Expand Down Expand Up @@ -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");

Expand All @@ -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));
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1c8fb19

Please sign in to comment.