diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 214ddaa8c..3d23ec52f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -19,8 +19,10 @@ package com.jpexs.decompiler.flash.configuration; import com.jpexs.decompiler.flash.ApplicationInfo; import com.jpexs.decompiler.flash.exporters.modes.ExeExportMode; import com.jpexs.decompiler.flash.helpers.CodeFormatting; +import com.jpexs.decompiler.flash.helpers.FontHelper; import com.jpexs.decompiler.flash.importers.TextImportResizeTextBoundsMode; import com.jpexs.helpers.Helper; +import java.awt.Font; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; @@ -289,6 +291,12 @@ public class Configuration { @ConfigurationName("gui.fontSizeMultiplier") public static final ConfigurationItem guiFontSizeMultiplier = null; + // font used in AS1/2/3 source area, P-Code area, Define Text area and in Metadata area + @ConfigurationDefaultString("Monospaced-Plain-12") + @ConfigurationCategory("display") + @ConfigurationName("gui.sourceFont") + public static final ConfigurationItem sourceFontString = null; + @ConfigurationDefaultDouble(0.5) @ConfigurationName("gui.avm2.splitPane.dividerLocationPercent") @ConfigurationInternal @@ -707,6 +715,10 @@ public class Configuration { return ret; } + public static Font getSourceFont() { + return FontHelper.stringToFont(sourceFontString.get()); + } + public static List getRecentFiles() { String files = recentFiles.get(); if (files == null || files.isEmpty()) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java index a53cdd929..2ff2ba313 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java @@ -63,19 +63,19 @@ public class FontHelper { Object fm = getFontManager(); Class clFm = Class.forName("sun.font.SunFontManager"); - //Delete cached installed names + // Delete cached installed names Field inField = clFm.getDeclaredField("installedNames"); inField.setAccessible(true); inField.set(null, null); inField.setAccessible(false); - //Delete cached family names + // Delete cached family names Field allFamField = clFm.getDeclaredField("allFamilies"); allFamField.setAccessible(true); allFamField.set(fm, null); allFamField.setAccessible(false); - //Delete cached fonts + // Delete cached fonts Field allFonField = clFm.getDeclaredField("allFonts"); allFonField.setAccessible(true); allFonField.set(fm, null); @@ -93,7 +93,7 @@ public class FontHelper { List javaFonts = Arrays.asList("Dialog", "DialogInput", "Monospaced", "Serif", "SansSerif"); for (Font f : fonts) { String fam = f.getFamily(Locale.ENGLISH); - //Do not want Java logical fonts + // Do not want Java logical fonts if (javaFonts.contains(fam)) { continue; } @@ -107,6 +107,31 @@ public class FontHelper { return ret; } + public static String fontToString(Font font) { + int style = font.getStyle(); + String styleString; + switch (style) { + case 1: + styleString = "Bold"; + break; + case 2: + styleString = "Italic"; + break; + case 3: + styleString = "BoldItalic"; + break; + default: + styleString = "Plain"; + break; + } + + return font.getName() + "-" + styleString + "-" + font.getSize(); + } + + public static Font stringToFont(String fontString) { + return Font.decode(fontString); + } + /** * Gets kerning offset for two characters of the font * diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index 0d4aff176..2cc05a333 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -77,7 +77,6 @@ import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; import java.awt.Component; -import java.awt.Font; import java.awt.Insets; import java.awt.event.ActionEvent; import java.io.BufferedInputStream; @@ -400,7 +399,7 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel //metadataEditor.setContentType("text/xml"); metadataEditor.setEditable(false); - metadataEditor.setFont(new Font("Monospaced", Font.PLAIN, metadataEditor.getFont().getSize())); + metadataEditor.setFont(Configuration.getSourceFont()); metadataEditor.changeContentType("text/xml"); metadataEditor.addTextChangedListener(this::metadataTextChanged); diff --git a/src/com/jpexs/decompiler/flash/gui/TextPanel.java b/src/com/jpexs/decompiler/flash/gui/TextPanel.java index 5ea6c165a..7ae120be2 100644 --- a/src/com/jpexs/decompiler/flash/gui/TextPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/TextPanel.java @@ -33,7 +33,6 @@ import com.jpexs.decompiler.flash.tags.text.TextParseException; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; -import java.awt.Font; import java.awt.Insets; import java.awt.event.ActionListener; import java.io.IOException; @@ -101,7 +100,7 @@ public class TextPanel extends JPanel implements TagEditorPanel { topPanel.add(textSearchPanel); textValue = new LineMarkedEditorPane(); add(new JScrollPane(textValue), BorderLayout.CENTER); - textValue.setFont(new Font("Monospaced", Font.PLAIN, textValue.getFont().getSize())); + textValue.setFont(Configuration.getSourceFont()); textValue.changeContentType("text/swftext"); textValue.addTextChangedListener(this::textChanged); @@ -392,12 +391,10 @@ public class TextPanel extends JPanel implements TagEditorPanel { try { TextTag copyTextTag = (TextTag) textTag.cloneTag(); if (copyTextTag.setFormattedText(new MissingCharacterHandler() { - @Override public boolean handle(TextTag textTag, FontTag font, char character) { return false; } - }, textValue.getText(), null)) { ok = true; mainPanel.showTextTagWithNewValue(textTag, copyTextTag); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index 4c66bfa51..2c99fa210 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -82,7 +82,6 @@ import de.hameister.treetable.MyTreeTableModel; import java.awt.BorderLayout; import java.awt.Cursor; import java.awt.FlowLayout; -import java.awt.Font; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -955,7 +954,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener