Skip to content

Commit

Permalink
Convex Desktop font edits
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Apr 23, 2024
1 parent fcb419d commit 461b9d4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
3 changes: 3 additions & 0 deletions convex-gui/src/main/java/convex/gui/components/CodeLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

import convex.gui.utils.Toolkit;

/**
* A simple label for multi-line text / code components
*/
@SuppressWarnings("serial")
public class CodeLabel extends JTextArea {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public AccountsPanel(Convex convex,StateModel<State> model) {

table.setCellSelectionEnabled(true);

table.setFont(Toolkit.SMALL_MONO_FONT);
table.getTableHeader().setFont(Toolkit.SMALL_MONO_FONT);
//table.setFont(Toolkit.SMALL_MONO_FONT);
//table.getTableHeader().setFont(Toolkit.SMALL_MONO_FONT);
((DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer()).setHorizontalAlignment(JLabel.LEFT);

model.addPropertyChangeListener(pc -> {
Expand Down Expand Up @@ -94,7 +94,6 @@ public AccountsPanel(Convex convex,StateModel<State> model) {
table.getColumnModel().getColumn(7).setPreferredWidth(200);
table.getColumnModel().getColumn(7).setCellRenderer(rightRenderer);

// popup menu, not sure why this doesn't work....
final JPopupMenu popupMenu = new JPopupMenu();
JMenuItem copyItem = new JMenuItem("Copy Value");
copyItem.addActionListener(new ActionListener() {
Expand Down
20 changes: 11 additions & 9 deletions convex-gui/src/main/java/convex/gui/utils/Toolkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,21 @@ public class Toolkit {
}
}

InputStream is = Utils.getResourceAsStream("fonts/SourceCodePro-Regular.ttf");
MONO_FONT = Font.createFont(Font.TRUETYPE_FONT, is);
SMALL_MONO_FONT = MONO_FONT.deriveFont(14f);
SMALL_MONO_BOLD = SMALL_MONO_FONT.deriveFont(Font.BOLD);

// prefer MaterialLookAndFeel if we have it
AbstractMaterialTheme theme = new MaterialOceanicTheme();
MaterialLookAndFeel material = new MaterialLookAndFeel(theme);

DEFAULT_FONT=theme.getFontRegular().deriveFont(14.0f);
theme.setFontRegular(new FontUIResource(DEFAULT_FONT.deriveFont(14.0f)));
theme.setFontBold(new FontUIResource(theme.getFontBold().deriveFont(14.0f)));
theme.setFontItalic(new FontUIResource(theme.getFontItalic().deriveFont(14.0f)));
theme.setFontMedium(new FontUIResource(theme.getFontMedium().deriveFont(14.0f)));
DEFAULT_FONT=DEFAULT_FONT.deriveFont(14.0f).deriveFont(Font.PLAIN);
// DEFAULT_FONT=SMALL_MONO_FONT;
theme.setFontRegular(new FontUIResource(DEFAULT_FONT));
theme.setFontBold(new FontUIResource(DEFAULT_FONT.deriveFont(Font.BOLD)));
theme.setFontItalic(new FontUIResource(DEFAULT_FONT.deriveFont(Font.ITALIC)));
theme.setFontMedium(new FontUIResource(DEFAULT_FONT.deriveFont(Font.PLAIN)));

UIManager.getLookAndFeelDefaults().put("TextField.caretForeground", Color.white);

Expand All @@ -89,10 +95,6 @@ public class Toolkit {
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.META_DOWN_MASK), DefaultEditorKit.cutAction);
}

InputStream is = Utils.getResourceAsStream("fonts/SourceCodePro-Regular.ttf");
Font monoFont = Font.createFont(Font.TRUETYPE_FONT, is);
SMALL_MONO_FONT = monoFont.deriveFont(14f);
SMALL_MONO_BOLD = SMALL_MONO_FONT.deriveFont(Font.BOLD);

UIManager.setLookAndFeel(material);
} catch (Exception e) {
Expand Down

0 comments on commit 461b9d4

Please sign in to comment.