fix(gui): correct font save with '-' in name (#1116)

This commit is contained in:
Skylot
2021-02-12 17:17:41 +00:00
parent 712389ab24
commit e6588c4307
2 changed files with 10 additions and 4 deletions
@@ -25,6 +25,7 @@ import com.beust.jcommander.Parameter;
import jadx.api.JadxArgs;
import jadx.cli.JadxCLIArgs;
import jadx.cli.LogHelper;
import jadx.core.utils.exceptions.JadxRuntimeException;
import jadx.gui.ui.MainWindow;
import jadx.gui.ui.codearea.EditorTheme;
import jadx.gui.utils.FontUtils;
@@ -36,7 +37,7 @@ public class JadxSettings extends JadxCLIArgs {
private static final Path USER_HOME = Paths.get(System.getProperty("user.home"));
private static final int RECENT_PROJECTS_COUNT = 15;
private static final int CURRENT_SETTINGS_VERSION = 10;
private static final int CURRENT_SETTINGS_VERSION = 11;
private static final Font DEFAULT_FONT = new RSyntaxTextArea().getFont();
@@ -485,6 +486,11 @@ public class JadxSettings extends JadxCLIArgs {
if (fromVersion == 10) {
srhResourceSkipSize = 3;
srhResourceFileExt = ".xml|.html|.js|.json|.txt";
fontStr = fontStr.replace('-', '/');
fromVersion++;
}
if (fromVersion != CURRENT_SETTINGS_VERSION) {
throw new JadxRuntimeException("Incorrect settings upgrade");
}
settingsVersion = CURRENT_SETTINGS_VERSION;
sync();
@@ -24,7 +24,7 @@ public class FontUtils {
}
public static Font loadByStr(String fontDesc) {
String[] parts = fontDesc.split("-");
String[] parts = fontDesc.split("/");
if (parts.length != 3) {
throw new JadxRuntimeException("Unsupported font description format: " + fontDesc);
}
@@ -42,8 +42,8 @@ public class FontUtils {
public static String convertToStr(Font font) {
return font.getFontName()
+ '-' + convertFontStyleToString(font.getStyle())
+ '-' + font.getSize();
+ '/' + convertFontStyleToString(font.getStyle())
+ '/' + font.getSize();
}
public static String convertFontStyleToString(int style) {