Skip to content

Commit

Permalink
[Fix] use "MS Gothic" rather than "Arial" on Win (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
funa-tk committed Oct 2, 2019
1 parent 067cfe1 commit ceed806
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 18 deletions.
12 changes: 10 additions & 2 deletions src/main/java/core/packetproxy/gui/BinaryTextPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,20 @@ public class BinaryTextPane extends ExtendedTextPane

public BinaryTextPane() {
setEditorKit(editor);
setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
if (Utils.isWindows()) {
setFont(new Font("MS ゴシック", Font.PLAIN, 13));
} else {
setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
}

JPopupMenu menu = new JPopupMenu();

JMenuItem title_encoders = new JMenuItem("エンコーダ");
title_encoders.setFont(new Font("Arial", Font.BOLD, 12));
if (Utils.isWindows()) {
title_encoders.setFont(new Font("MS ゴシック", Font.PLAIN, 13));
} else {
title_encoders.setFont(new Font("Arial", Font.BOLD, 12));
}
title_encoders.setEnabled(false);
menu.add(title_encoders);

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/core/packetproxy/gui/ExtendedTextPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ abstract class ExtendedTextPane extends JTextPane

public ExtendedTextPane() {
setEditorKit(editor);
setFont(new Font(Font.MONOSPACED, Font.PLAIN, FONT_SIZE));
if (Utils.isWindows()) {
setFont(new Font("MS ゴシック", Font.PLAIN, 13));
} else {
setFont(new Font(Font.MONOSPACED, Font.PLAIN, FONT_SIZE));
}
getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
Expand Down
31 changes: 26 additions & 5 deletions src/main/java/core/packetproxy/gui/GUIHistoryBinary.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Arrays;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.*;

import org.apache.commons.lang3.ArrayUtils;

import packetproxy.common.Binary;
import packetproxy.common.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
import packetproxy.common.Utils;

public class GUIHistoryBinary extends GUIHistoryPanel implements BinaryTextPane.DataChangedListener
{
Expand All @@ -52,7 +61,11 @@ public GUIHistoryBinary()
hex_text.setParentHistory(this);
hex_text.addDataChangedListener(this);
//hex_text.setLineWrap(true);
hex_text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
if (Utils.isWindows()) {
hex_text.setFont(new Font("MS ゴシック", Font.PLAIN, 13));
} else {
hex_text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
}
hex_text.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
Expand Down Expand Up @@ -103,7 +116,11 @@ public void keyTyped(KeyEvent arg0) {

ascii_text = new JTextPane();
//ascii_text.setLineWrap(true);
ascii_text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
if (Utils.isWindows()) {
ascii_text.setFont(new Font("MS ゴシック", Font.PLAIN, 13));
} else {
ascii_text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
}
ascii_text.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
Expand All @@ -128,7 +145,11 @@ public void mouseReleased(MouseEvent e) {
scrollpane4.getVerticalScrollBar().setModel(scrollpane3.getVerticalScrollBar().getModel()); // 縦方向のスクロールをhex側と同期させる

search_text = new JTextField();
search_text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
if (Utils.isWindows()) {
search_text.setFont(new Font("MS ゴシック", Font.PLAIN, 13));
} else {
search_text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
}
search_text.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent arg0) {
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/core/packetproxy/gui/GUIMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
import javax.swing.text.DefaultEditorKit;
import javax.swing.text.JTextComponent;
import javax.swing.text.Keymap;

import com.sun.javafx.util.Utils;

import packetproxy.model.InterceptModel;
import packetproxy.model.Packets;
import packetproxy.util.PacketProxyUtility;
Expand Down Expand Up @@ -175,8 +178,11 @@ private void setLookandFeel() throws Exception {
}
//Windowsだと日本語フォントを指定しないと文字化けする
//TODO FONT指定は一か所に集める
UIManager.getLookAndFeelDefaults().put("defaultFont", new Font("MS ゴシック", Font.PLAIN, 12));
//UIManager.getLookAndFeelDefaults().put("defaultFont", new Font("Arial", Font.PLAIN, 12));
if (Utils.isWindows()) {
UIManager.getLookAndFeelDefaults().put("defaultFont", new Font("MS ゴシック", Font.PLAIN, 13));
} else {
UIManager.getLookAndFeelDefaults().put("defaultFont", new Font("Arial", Font.PLAIN, 12));
}
setIconForWindows();
addShortcutForMac();
addDockIconForMac();
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/core/packetproxy/gui/GUIOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

import org.apache.commons.io.FileUtils;

import packetproxy.common.Utils;
import packetproxy.model.CAFactory;
import packetproxy.model.CAs.CA;

Expand All @@ -52,7 +53,11 @@ private JComponent createTitle(String title) {
JLabel label = new JLabel(title);
label.setForeground(Color.ORANGE);
label.setBackground(Color.WHITE);
label.setFont(new Font("Arial", Font.BOLD, 14));
if (Utils.isWindows()) {
label.setFont(new Font("Arial", Font.BOLD, 15));
} else {
label.setFont(new Font("Arial", Font.BOLD, 14));
}
int label_height = label.getMaximumSize().height;
label.setMaximumSize(new Dimension(Short.MAX_VALUE, label_height));
return label;
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/core/packetproxy/gui/HintTextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import java.awt.event.FocusListener;
import javax.swing.JTextField;

import packetproxy.common.Utils;

public class HintTextField extends JTextField
{
private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -74,12 +76,16 @@ protected void paintComponent(Graphics g) {
Font oldFont=g2.getFont();
Color oldColor=g2.getColor();
{
g2.setFont(getFont().deriveFont(Font.ITALIC));
g2.setColor(Color.GRAY);

Insets insets=getBorder().getBorderInsets(this);
int h=g2.getFontMetrics().getAscent();
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

if (Utils.isWindows()) {
g2.setColor(Color.LIGHT_GRAY);
} else {
g2.setFont(getFont().deriveFont(Font.ITALIC));
g2.setColor(Color.GRAY);
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
g2.drawString(getHint(),insets.left,insets.top+h);
}
g2.setFont(oldFont);
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/core/packetproxy/gui/RawTextPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,13 @@ public void keyPressed(KeyEvent e) {
}
});

menu.addSeparator();
JMenuItem title_decoders = new JMenuItem("デコーダ");
title_decoders.setFont(new Font("Arial", Font.BOLD, 12));
if (Utils.isWindows()) {
title_decoders.setFont(new Font("MS ゴシック", Font.BOLD, 13));
} else {
title_decoders.setFont(new Font("Arial", Font.BOLD, 12));
}
title_decoders.setEnabled(false);
menu.add(title_decoders);

Expand Down Expand Up @@ -210,7 +215,11 @@ public void actionPerformed(ActionEvent actionEvent) {

menu.addSeparator();
JMenuItem title_encoders = new JMenuItem("エンコーダ");
title_encoders.setFont(new Font("Arial", Font.BOLD, 12));
if (Utils.isWindows()) {
title_encoders.setFont(new Font("MS ゴシック", Font.BOLD, 13));
} else {
title_encoders.setFont(new Font("Arial", Font.BOLD, 12));
}
title_encoders.setEnabled(false);
menu.add(title_encoders);

Expand Down
9 changes: 8 additions & 1 deletion src/main/java/core/packetproxy/util/SearchBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import java.awt.event.KeyListener;
import javax.swing.JTextField;
import javax.swing.JTextPane;

import packetproxy.common.Utils;

import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.BoxLayout;
Expand All @@ -45,7 +48,11 @@ public String getText() {

public SearchBox() {
search_text = new JTextField();
search_text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
if (Utils.isWindows()) {
search_text.setFont(new Font("MS ゴシック", Font.PLAIN, 13));
} else {
search_text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
}
search_text.addKeyListener(new KeyListener() {
private String prev_word = null;
private int cur_pos = 0;
Expand Down

0 comments on commit ceed806

Please sign in to comment.