From d5dab2bb606cbc3e0c7d1a52de348a09e58de720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Mon, 6 Nov 2023 23:19:12 +0100 Subject: [PATCH] Fixed #2116 DefineEditText display - correct getting fonts Fixed #2116 DefineEditText display - apostroph decoding --- CHANGELOG.md | 4 ++++ .../src/com/jpexs/decompiler/flash/SWF.java | 5 +++-- .../flash/tags/DefineEditTextTag.java | 19 +++++++++++-------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed6003f51..9fd41815a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file. ### Fixed - [#2021], [#2000] Caret position in editors when using tabs and / or unicode - [#2021] Indent continuation when using tabs +- [#2116] DefineEditText display - correct getting fonts +- [#2116] DefineEditText display - apostroph decoding + ## [20.0.0] - 2023-11-05 ### Added @@ -3257,6 +3260,7 @@ Major version of SWF to XML export changed to 2. [alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7 [#2021]: https://www.free-decompiler.com/flash/issues/2021 [#2000]: https://www.free-decompiler.com/flash/issues/2000 +[#2116]: https://www.free-decompiler.com/flash/issues/2116 [#1130]: https://www.free-decompiler.com/flash/issues/1130 [#1220]: https://www.free-decompiler.com/flash/issues/1220 [#1717]: https://www.free-decompiler.com/flash/issues/1717 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 0a2a537ca..b2d65e7b8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -851,13 +851,14 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { return null; } - public FontTag getFontByNameInTag(String fontName) { + public FontTag getFontByNameInTag(String fontName, boolean bold, boolean italic) { if (fontName == null) { return null; } for (Tag t : getTags()) { if (t instanceof FontTag) { - if (fontName.equals(((FontTag) t).getFontNameIntag())) { + FontTag ft = (FontTag) t; + if (fontName.equals(ft.getFontNameIntag()) && ft.isBold() == bold && ft.isItalic() == italic) { return (FontTag) t; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java index 6e176927b..1daaad54a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java @@ -415,7 +415,7 @@ public class DefineEditTextTag extends TextTag { case "b": style = style.clone(); style.bold = true; - styles.add(style); + styles.add(style); break; case "i": style = style.clone(); @@ -454,12 +454,7 @@ public class DefineEditTextTag extends TextTag { String face = unescape(attributes.getValue("face")); if (face != null && face.length() > 0) { - style.fontFace = face; - FontTag insideFont = swf.getFontByNameInTag(face); - style.font = insideFont; - if (insideFont != null) { - style.fontFace = null; - } + style.fontFace = face; } String letterspacing = unescape(attributes.getValue("letterSpacing")); @@ -512,6 +507,7 @@ public class DefineEditTextTag extends TextTag { txt = txt.replace("/{entity-gt}", ">"); txt = txt.replace("/{entity-quot}", "\""); txt = txt.replace("/{entity-amp}", "&"); + txt = txt.replace("/{entity-apos}", "'"); return txt; } @@ -519,6 +515,12 @@ public class DefineEditTextTag extends TextTag { public void characters(char[] ch, int start, int length) throws SAXException { String txt = unescape(new String(ch, start, length)); TextStyle style = styles.peek(); + if (style.fontFace != null) { + style.font = swf.getFontByNameInTag(style.fontFace, style.bold, style.italic); + if (style.font == null) { + style.fontFace = null; + } + } addCharacters(ret, txt, style); } }; @@ -528,6 +530,7 @@ public class DefineEditTextTag extends TextTag { str = str.replace(">", "/{entity-gt}"); str = str.replace(""", "/{entity-quot}"); str = str.replace("&", "/{entity-amp}"); + str = str.replace("'", "/{entity-apos}"); str = str.replace("&", "&"); str = "