提交 6df31501 编写于 作者: S Skylot

gui: add Hack font

上级 1931e783
...@@ -40,7 +40,7 @@ jar { ...@@ -40,7 +40,7 @@ jar {
} }
startScripts { startScripts {
defaultJvmOpts = ['-Xms128M', '-Xmx4g'] defaultJvmOpts = ['-Xms128M', '-Xmx4g', '-Dawt.useSystemAAFontSettings=lcd', '-Dswing.aatext=true']
doLast { doLast {
def str = windowsScript.text def str = windowsScript.text
str = str.replaceAll('java.exe', 'javaw.exe') str = str.replaceAll('java.exe', 'javaw.exe')
...@@ -58,10 +58,12 @@ launch4j { ...@@ -58,10 +58,12 @@ launch4j {
outfile = "jadx-gui-${version}.exe" outfile = "jadx-gui-${version}.exe"
copyright = 'Skylot' copyright = 'Skylot'
windowTitle = 'jadx' windowTitle = 'jadx'
jvmOptions = ['-Dawt.useSystemAAFontSettings=lcd', '-Dswing.aatext=true']
jreRuntimeBits = "64" jreRuntimeBits = "64"
initialHeapPercent = 5 initialHeapPercent = 5
maxHeapSize = 4096 maxHeapSize = 4096
maxHeapPercent = 70 maxHeapPercent = 70
} }
test { test {
......
...@@ -16,6 +16,8 @@ import org.slf4j.LoggerFactory; ...@@ -16,6 +16,8 @@ import org.slf4j.LoggerFactory;
import jadx.api.JadxArgs; import jadx.api.JadxArgs;
import jadx.cli.JadxCLIArgs; import jadx.cli.JadxCLIArgs;
import static jadx.gui.utils.Utils.FONT_HACK;
public class JadxSettings extends JadxCLIArgs { public class JadxSettings extends JadxCLIArgs {
private static final Logger LOG = LoggerFactory.getLogger(JadxSettings.class); private static final Logger LOG = LoggerFactory.getLogger(JadxSettings.class);
...@@ -23,7 +25,7 @@ public class JadxSettings extends JadxCLIArgs { ...@@ -23,7 +25,7 @@ public class JadxSettings extends JadxCLIArgs {
private static final int RECENT_FILES_COUNT = 15; private static final int RECENT_FILES_COUNT = 15;
private static final int CURRENT_SETTINGS_VERSION = 1; private static final int CURRENT_SETTINGS_VERSION = 1;
private static final Font DEFAULT_FONT = new RSyntaxTextArea().getFont(); private static final Font DEFAULT_FONT = FONT_HACK != null ? FONT_HACK : new RSyntaxTextArea().getFont();
static final Set<String> SKIP_FIELDS = new HashSet<>(Arrays.asList( static final Set<String> SKIP_FIELDS = new HashSet<>(Arrays.asList(
"files", "input", "outputDir", "verbose", "printHelp" "files", "input", "outputDir", "verbose", "printHelp"
......
...@@ -19,6 +19,8 @@ import say.swing.JFontChooser; ...@@ -19,6 +19,8 @@ import say.swing.JFontChooser;
import jadx.gui.ui.MainWindow; import jadx.gui.ui.MainWindow;
import jadx.gui.utils.NLS; import jadx.gui.utils.NLS;
import static jadx.gui.utils.Utils.FONT_HACK;
public class JadxSettingsWindow extends JDialog { public class JadxSettingsWindow extends JDialog {
private static final long serialVersionUID = -1804570470377354148L; private static final long serialVersionUID = -1804570470377354148L;
...@@ -37,6 +39,7 @@ public class JadxSettingsWindow extends JDialog { ...@@ -37,6 +39,7 @@ public class JadxSettingsWindow extends JDialog {
this.startSettings = JadxSettingsAdapter.makeString(settings); this.startSettings = JadxSettingsAdapter.makeString(settings);
initUI(); initUI();
registerBundledFonts();
setTitle(NLS.str("preferences.title")); setTitle(NLS.str("preferences.title"));
setSize(400, 550); setSize(400, 550);
...@@ -46,6 +49,13 @@ public class JadxSettingsWindow extends JDialog { ...@@ -46,6 +49,13 @@ public class JadxSettingsWindow extends JDialog {
pack(); pack();
} }
public static void registerBundledFonts() {
GraphicsEnvironment grEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
if (FONT_HACK != null) {
grEnv.registerFont(FONT_HACK);
}
}
private void initUI() { private void initUI() {
JPanel panel = new JPanel(); JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
......
package jadx.gui.utils; package jadx.gui.utils;
import javax.swing.*; import java.awt.*;
import java.io.InputStream;
import java.net.URL; import java.net.URL;
import javax.swing.*;
import jadx.core.dex.info.AccessInfo; import jadx.core.dex.info.AccessInfo;
import jadx.core.dex.instructions.args.ArgType; import jadx.core.dex.instructions.args.ArgType;
import jadx.core.utils.exceptions.JadxRuntimeException; import jadx.core.utils.exceptions.JadxRuntimeException;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Utils { public class Utils {
private static final Logger LOG = LoggerFactory.getLogger(Utils.class);
private static final ImageIcon ICON_STATIC = openIcon("static_co");
private static final ImageIcon ICON_FINAL = openIcon("final_co");
private static final ImageIcon ICON_ABSTRACT = openIcon("abstract_co");
private static final ImageIcon ICON_NATIVE = openIcon("native_co");
private static final ImageIcon ICON_STATIC = Utils.openIcon("static_co"); public static final Font FONT_HACK = openFontTTF("Hack-Regular");
private static final ImageIcon ICON_FINAL = Utils.openIcon("final_co");
private static final ImageIcon ICON_ABSTRACT = Utils.openIcon("abstract_co");
private static final ImageIcon ICON_NATIVE = Utils.openIcon("native_co");
private Utils() { private Utils() {
} }
...@@ -26,6 +34,18 @@ public class Utils { ...@@ -26,6 +34,18 @@ public class Utils {
return new ImageIcon(resource); return new ImageIcon(resource);
} }
@Nullable
public static Font openFontTTF(String name) {
String fontPath = "/fonts/" + name + ".ttf";
try (InputStream is = Utils.class.getResourceAsStream(fontPath)) {
Font font = Font.createFont(Font.TRUETYPE_FONT, is);
return font.deriveFont(12f);
} catch (Exception e) {
LOG.error("Failed load font by path: {}", fontPath, e);
return null;
}
}
public static void addKeyBinding(JComponent comp, KeyStroke key, String id, Action action) { public static void addKeyBinding(JComponent comp, KeyStroke key, String id, Action action) {
comp.getInputMap().put(key, id); comp.getInputMap().put(key, id);
comp.getActionMap().put(id, action); comp.getActionMap().put(id, action);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册