From b9abe1a5fac3e7680e0cab358f08efdce2b34ef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 17 Sep 2016 17:16:25 +0200 Subject: [PATCH 1/8] #1281 DefineFont2/3 getting character advance when replacing fix --- .../src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java | 6 +++--- .../src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) 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..56879aa9b 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))); } } 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..667a3d014 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))); } } From 42cec207fd71ff1218fd4705d45afcbcee1ee379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 17 Sep 2016 17:20:56 +0200 Subject: [PATCH 2/8] #1281 DefineFont2/3 set advance value by deriving font --- .../src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java | 4 ++-- .../src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 56879aa9b..f93aed32b 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 @@ -540,8 +540,8 @@ public class DefineFont2Tag extends FontTag { SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, (int) Math.round(getDivider() * 1024), ch); fontBoundsTable.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 + fontAdvanceTable.add((int) getDivider() * Math.round(FontHelper.getFontAdvance(advanceFont, ch))); } } 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 667a3d014..cb0cb0f3a 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 @@ -545,8 +545,8 @@ public class DefineFont3Tag extends FontTag { SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, (int) Math.round(getDivider() * 1024), ch); fontBoundsTable.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 + fontAdvanceTable.add((int) getDivider() * Math.round(FontHelper.getFontAdvance(advanceFont, ch))); } } From 51f4608d1a4da0e34448f9284ae4579d494b740f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 17 Sep 2016 17:23:50 +0200 Subject: [PATCH 3/8] Do not set advance if it can't display char --- .../src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java | 3 +++ .../src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java | 3 +++ 2 files changed, 6 insertions(+) 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 f93aed32b..e3163c0cc 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 @@ -537,6 +537,9 @@ public class DefineFont2Tag extends FontTag { for (Integer character : codeTable) { char ch = (char) (int) character; + if (!font.canDisplay(ch)) { + continue; + } SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, (int) Math.round(getDivider() * 1024), ch); fontBoundsTable.add(shp.getBounds()); int fontStyle = getFontStyle(); 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 cb0cb0f3a..7ba932956 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 @@ -542,6 +542,9 @@ public class DefineFont3Tag extends FontTag { for (Integer character : codeTable) { char ch = (char) (int) character; + if (!font.canDisplay(ch)) { + continue; + } SHAPE shp = SHAPERECORD.fontCharacterToSHAPE(font, (int) Math.round(getDivider() * 1024), ch); fontBoundsTable.add(shp.getBounds()); int fontStyle = getFontStyle(); From 42eda53a625ce8e5e2fd098ea9463b2994bafab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 17 Sep 2016 17:35:11 +0200 Subject: [PATCH 4/8] Set advance values correctly when font does not support the character --- .../decompiler/flash/tags/DefineFont2Tag.java | 25 ++++++++++--------- .../decompiler/flash/tags/DefineFont3Tag.java | 25 ++++++++++--------- 2 files changed, 26 insertions(+), 24 deletions(-) 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 e3163c0cc..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 @@ -527,25 +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)) { + 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 advanceFont = font.deriveFont(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(advanceFont, ch))); + 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 7ba932956..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 @@ -532,25 +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)) { + 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 advanceFont = font.deriveFont(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(advanceFont, ch))); + newFontAdvanceTable.add((int) getDivider() * Math.round(FontHelper.getFontAdvance(advanceFont, ch))); } + fontAdvanceTable = newFontAdvanceTable; + fontBoundsTable = newFontBoundsTable; + fontKerningTable = new ArrayList<>(); + fontFlagsHasLayout = true; } @Override From 6e74ff5951a22f6a9670fddece7112f4e1a66c24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 17 Sep 2016 17:46:27 +0200 Subject: [PATCH 5/8] Set advance values has confirm message --- src/com/jpexs/decompiler/flash/gui/FontPanel.java | 4 +++- .../flash/gui/locales/AdvancedSettingsDialog.properties | 5 ++++- .../jpexs/decompiler/flash/gui/locales/MainFrame.properties | 4 +++- .../decompiler/flash/gui/locales/MainFrame_cs.properties | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) 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 65c5f29d9..5f992623c 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -769,4 +769,6 @@ error.debug.watch.add = Cannot add watch to this variable. variables.column.scope = Scope variables.column.flags = Flags -variables.column.trait = Trait \ No newline at end of file +variables.column.trait = Trait + +message.font.setadvancevalues = This operation will set advance of ALL characters in this tag to selected font source advances. \ No newline at end of file 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 From 7012c296ee9332326afa041d5dbfdc021927c630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 17 Sep 2016 17:48:04 +0200 Subject: [PATCH 6/8] Missing config --- .../jpexs/decompiler/flash/configuration/Configuration.java | 4 ++++ 1 file changed, 4 insertions(+) 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 From 65d97bec0785949f1893d84c3bb60d0980685093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 17 Sep 2016 17:59:57 +0200 Subject: [PATCH 7/8] commit just to make nightly --- .../com/jpexs/decompiler/flash/configuration/Configuration.java | 1 + 1 file changed, 1 insertion(+) 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 9f5993f55..5a335ce5f 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 @@ -1072,4 +1072,5 @@ public class Configuration { return null; } + //remove this } From afc3f40ecef7c2c58e7721602f25cdf519719437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 17 Sep 2016 18:00:10 +0200 Subject: [PATCH 8/8] remove again --- .../com/jpexs/decompiler/flash/configuration/Configuration.java | 1 - 1 file changed, 1 deletion(-) 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 5a335ce5f..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 @@ -1072,5 +1072,4 @@ public class Configuration { return null; } - //remove this }