From 634661106026bfd09a746ec326009732e1edb36e Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Tue, 28 Jul 2015 19:05:37 +0200 Subject: [PATCH] write fontnames with default endcoding for swfs having version 5 or less --- .../src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java | 1 - .../src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java | 6 +++++- .../src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java | 6 +++++- .../com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java | 6 +++++- .../com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java | 6 +++++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 9e456edb8..55bb816a7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -2270,7 +2270,6 @@ public class AVM2Code implements Cloneable { new AVM2DeobfuscatorSimple().deobfuscate(path, classIndex, isStatic, scriptIndex, abc, constants, trait, info, body); new AVM2DeobfuscatorRegisters().deobfuscate(path, classIndex, isStatic, scriptIndex, abc, constants, trait, info, body); new AVM2DeobfuscatorJumps().deobfuscate(path, classIndex, isStatic, scriptIndex, abc, constants, trait, info, body); - //body.getCode().checkValidOffsets(body); // todo: only for debugging. checkValidOffsets can be made private later return 1; } } 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 8fc2f6acf..6a512250a 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 @@ -211,7 +211,11 @@ public class DefineFont2Tag extends FontTag { sos.writeUB(1, fontFlagsItalic ? 1 : 0); sos.writeUB(1, fontFlagsBold ? 1 : 0); sos.writeLANGCODE(languageCode); - sos.writeNetString(fontName, Utf8Helper.charset); // todo: check swf version and write non utf-8 for version < 6 + if (swf.version >= 6) { + sos.writeNetString(fontName, Utf8Helper.charset); + } else { + sos.writeNetString(fontName); + } int numGlyphs = glyphShapeTable.size(); sos.writeUI16(numGlyphs); 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 dbf3214d7..dabe762aa 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 @@ -219,7 +219,11 @@ public class DefineFont3Tag extends FontTag { sos.writeUB(1, fontFlagsItalic ? 1 : 0); sos.writeUB(1, fontFlagsBold ? 1 : 0); sos.writeLANGCODE(languageCode); - sos.writeNetString(fontName, Utf8Helper.charset); // todo: check swf version and write non utf-8 for version < 6 + if (swf.version >= 6) { + sos.writeNetString(fontName, Utf8Helper.charset); + } else { + sos.writeNetString(fontName); + } sos.writeUI16(numGlyphs); for (long offset : offsetTable) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java index 80774ce94..7ce2026cc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java @@ -122,7 +122,11 @@ public class DefineFontInfo2Tag extends Tag implements CharacterIdTag { @Override public void getData(SWFOutputStream sos) throws IOException { sos.writeUI16(fontID); - sos.writeNetString(fontName, Utf8Helper.charset); // todo: check swf version and write non utf-8 for version < 6 + if (swf.version >= 6) { + sos.writeNetString(fontName, Utf8Helper.charset); + } else { + sos.writeNetString(fontName); + } sos.writeUB(2, reserved); sos.writeUB(1, fontFlagsSmallText ? 1 : 0); sos.writeUB(1, fontFlagsShiftJIS ? 1 : 0); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java index 26f6460a3..c511a5ccc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java @@ -120,7 +120,11 @@ public class DefineFontInfoTag extends Tag implements CharacterIdTag { @Override public void getData(SWFOutputStream sos) throws IOException { sos.writeUI16(fontId); - sos.writeNetString(fontName, Utf8Helper.charset); // todo: check swf version and write non utf-8 for version < 6 + if (swf.version >= 6) { + sos.writeNetString(fontName, Utf8Helper.charset); + } else { + sos.writeNetString(fontName); + } sos.writeUB(2, reserved); sos.writeUB(1, fontFlagsSmallText ? 1 : 0); sos.writeUB(1, fontFlagsShiftJIS ? 1 : 0);