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 b23c62052..9f5993f55 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 @@ -617,6 +617,10 @@ public class Configuration { @ConfigurationCategory("script") public static final ConfigurationItem useFlexAs3Compiler = null; + @ConfigurationDefaultBoolean(true) + @ConfigurationCategory("ui") + public static final ConfigurationItem showSetAdvanceValuesMessage = null; + private enum OSId { WINDOWS, OSX, UNIX diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java index e976871e0..264e5e69d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java @@ -475,13 +475,13 @@ public class DefineFont2Tag extends FontTag { } if (fontFlagsHasLayout) { - Font fnt = new Font(fontName, fontStyle, 1024); + Font advanceFont = font.deriveFont(fontStyle, 1024); // Not multiplied with divider as it causes problems to create font with height around 20k if (!exists) { fontBoundsTable.add(pos, shp.getBounds()); - fontAdvanceTable.add(pos, (int) getDivider() * Math.round(FontHelper.getFontAdvance(fnt, character))); + fontAdvanceTable.add(pos, (int) getDivider() * Math.round(FontHelper.getFontAdvance(advanceFont, character))); } else { fontBoundsTable.set(pos, shp.getBounds()); - fontAdvanceTable.set(pos, (int) getDivider() * Math.round(FontHelper.getFontAdvance(fnt, character))); + fontAdvanceTable.set(pos, (int) getDivider() * Math.round(FontHelper.getFontAdvance(advanceFont, character))); } } @@ -527,22 +527,26 @@ public class DefineFont2Tag extends FontTag { @Override public void setAdvanceValues(Font font) { - boolean hasLayout = fontFlagsHasLayout; - fontFlagsHasLayout = true; - fontAdvanceTable = new ArrayList<>(); - if (!hasLayout) { - fontBoundsTable = new ArrayList<>(); - fontKerningTable = new ArrayList<>(); - } - - for (Integer character : codeTable) { + List newFontBoundsTable = new ArrayList<>(); + List newFontAdvanceTable = new ArrayList<>(); + for (int i = 0; i < codeTable.size(); i++) { + Integer character = codeTable.get(i); char ch = (char) (int) character; + if (!font.canDisplay(ch) && fontFlagsHasLayout) { //cannot display, leave old if exist + newFontAdvanceTable.add(fontAdvanceTable.get(i)); + newFontBoundsTable.add(fontBoundsTable.get(i)); + continue; + } SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, (int) Math.round(getDivider() * 1024), ch); - fontBoundsTable.add(shp.getBounds()); + newFontBoundsTable.add(shp.getBounds()); int fontStyle = getFontStyle(); - Font fnt = new Font(font.getFontName(), fontStyle, 1024); // Not multiplied with divider as it causes problems to create font with height around 20k - fontAdvanceTable.add((int) getDivider() * Math.round(FontHelper.getFontAdvance(fnt, ch))); + Font advanceFont = font.deriveFont(fontStyle, 1024); // Not multiplied with divider as it causes problems to create font with height around 20k + newFontAdvanceTable.add((int) getDivider() * Math.round(FontHelper.getFontAdvance(advanceFont, ch))); } + fontAdvanceTable = newFontAdvanceTable; + fontBoundsTable = newFontBoundsTable; + fontKerningTable = new ArrayList<>(); + fontFlagsHasLayout = true; } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java index 504f87e89..f3eb86cee 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java @@ -468,13 +468,13 @@ public class DefineFont3Tag extends FontTag { } if (fontFlagsHasLayout) { - Font fnt = new Font(fontName, fontStyle, 1024); // Not multiplied with divider as it causes problems to create font with height around 20k + Font advanceFont = font.deriveFont(fontStyle, 1024); // Not multiplied with divider as it causes problems to create font with height around 20k if (!exists) { fontBoundsTable.add(pos, shp.getBounds()); - fontAdvanceTable.add(pos, (int) getDivider() * Math.round(FontHelper.getFontAdvance(fnt, character))); + fontAdvanceTable.add(pos, (int) getDivider() * Math.round(FontHelper.getFontAdvance(advanceFont, character))); } else { fontBoundsTable.set(pos, shp.getBounds()); - fontAdvanceTable.set(pos, (int) getDivider() * Math.round(FontHelper.getFontAdvance(fnt, character))); + fontAdvanceTable.set(pos, (int) getDivider() * Math.round(FontHelper.getFontAdvance(advanceFont, character))); } } @@ -532,22 +532,26 @@ public class DefineFont3Tag extends FontTag { @Override public void setAdvanceValues(Font font) { - boolean hasLayout = fontFlagsHasLayout; - fontFlagsHasLayout = true; - fontAdvanceTable = new ArrayList<>(); - if (!hasLayout) { - fontBoundsTable = new ArrayList<>(); - fontKerningTable = new ArrayList<>(); - } - - for (Integer character : codeTable) { + List newFontBoundsTable = new ArrayList<>(); + List newFontAdvanceTable = new ArrayList<>(); + for (int i = 0; i < codeTable.size(); i++) { + Integer character = codeTable.get(i); char ch = (char) (int) character; + if (!font.canDisplay(ch) && fontFlagsHasLayout) { //cannot display, leave old if exist + newFontAdvanceTable.add(fontAdvanceTable.get(i)); + newFontBoundsTable.add(fontBoundsTable.get(i)); + continue; + } SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, (int) Math.round(getDivider() * 1024), ch); - fontBoundsTable.add(shp.getBounds()); + newFontBoundsTable.add(shp.getBounds()); int fontStyle = getFontStyle(); - Font fnt = new Font(font.getFontName(), fontStyle, 1024); // Not multiplied with divider as it causes problems to create font with height around 20k - fontAdvanceTable.add((int) getDivider() * Math.round(FontHelper.getFontAdvance(fnt, ch))); + Font advanceFont = font.deriveFont(fontStyle, 1024); // Not multiplied with divider as it causes problems to create font with height around 20k + newFontAdvanceTable.add((int) getDivider() * Math.round(FontHelper.getFontAdvance(advanceFont, ch))); } + fontAdvanceTable = newFontAdvanceTable; + fontBoundsTable = newFontBoundsTable; + fontKerningTable = new ArrayList<>(); + fontFlagsHasLayout = true; } @Override diff --git a/src/com/jpexs/decompiler/flash/gui/FontPanel.java b/src/com/jpexs/decompiler/flash/gui/FontPanel.java index 8391f62c1..bec8215b4 100644 --- a/src/com/jpexs/decompiler/flash/gui/FontPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/FontPanel.java @@ -605,7 +605,9 @@ public class FontPanel extends JPanel { } private void buttonSetAdvanceValuesActionPerformed(ActionEvent evt) { - fontTag.setAdvanceValues(((FontFace) fontFaceSelection.getSelectedItem()).font); + if (View.showConfirmDialog(null, AppStrings.translate("message.font.setadvancevalues"), AppStrings.translate("message.warning"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, Configuration.showSetAdvanceValuesMessage, JOptionPane.OK_OPTION) == JOptionPane.OK_OPTION) { + fontTag.setAdvanceValues(((FontFace) fontFaceSelection.getSelectedItem()).font); + } } private void formComponentResized(ComponentEvent evt) { diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties index a0d3573ac..aa5af79cd 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties @@ -436,4 +436,7 @@ config.name.flexSdkLocation = 4) Flex SDK directory path config.description.flexSdkLocation = Location of Adobe Flex SDK. It is used mostly for AS3 compilation. config.name.useFlexAs3Compiler = Use Flex SDK AS3 compiler -config.description.useFlexAs3Compiler = Use AS3 compiler from Flex SDK while ActionScript direct editation (Flex SDK directory needs to be set) \ No newline at end of file +config.description.useFlexAs3Compiler = Use AS3 compiler from Flex SDK while ActionScript direct editation (Flex SDK directory needs to be set) + +config.name.showSetAdvanceValuesMessage = Show again information about setting advance values +config.description.showSetAdvanceValuesMessage = Show again information about setting advance values diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index 5d716e46c..7e0c09b88 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -771,4 +771,6 @@ variables.column.scope = Scope variables.column.flags = Flags variables.column.trait = Trait +message.font.setadvancevalues = This operation will set advance of ALL characters in this tag to selected font source advances. + menu.tools.deobfuscation.renameColliding = Rename colliding traits/classes diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties index 26d1b7807..9284a53b8 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties @@ -749,4 +749,6 @@ abc.detail.specialmethod.instanceinitializer = Inicializ\u00e1tor instance abc.detail.innerfunction = Vnit\u0159n\u00ed funkce button.edit.script.decompiled = Upravit ActionScript -button.edit.script.disassembled = Upravit P-k\u00f3d \ No newline at end of file +button.edit.script.disassembled = Upravit P-k\u00f3d + +message.font.setadvancevalues = Tato operace nastav\u00ed advance V\u0160ECH znak\u016f v tomto tagu na advance hodnoty zdrojov\u00e9ho p\u00edsma. \ No newline at end of file