From d68da494f0c8b43d6c282bc6b473ca3e3a7a5213 Mon Sep 17 00:00:00 2001 From: Honfika Date: Thu, 6 Feb 2014 18:03:45 +0100 Subject: [PATCH] Issue #504: font name reading fixed --- .../com/jpexs/decompiler/flash/tags/DefineFont2Tag.java | 6 +++++- .../com/jpexs/decompiler/flash/tags/DefineFont3Tag.java | 6 +++++- .../jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java | 6 +++++- .../com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java | 7 ++++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java index de47a18f9..8d13666d1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java @@ -214,7 +214,11 @@ public class DefineFont2Tag extends FontTag { fontFlagsBold = sis.readUB(1) == 1; languageCode = sis.readLANGCODE(); int fontNameLen = sis.readUI8(); - fontName = new String(sis.readBytesEx(fontNameLen)); + if (version >= 6) { + fontName = new String(sis.readBytesEx(fontNameLen), Utf8Helper.charset); + } else { + fontName = new String(sis.readBytesEx(fontNameLen)); + } numGlyphs = sis.readUI16(); //offsetTable = new long[numGlyphs]; for (int i = 0; i < numGlyphs; i++) { //offsetTable diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java index 85aa0143d..8b5dc4a56 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java @@ -124,7 +124,11 @@ public class DefineFont3Tag extends FontTag { fontFlagsBold = sis.readUB(1) == 1; languageCode = sis.readLANGCODE(); int fontNameLen = sis.readUI8(); - fontName = new String(sis.readBytesEx(fontNameLen)); + if (version >= 6) { + fontName = new String(sis.readBytesEx(fontNameLen), Utf8Helper.charset); + } else { + fontName = new String(sis.readBytesEx(fontNameLen)); + } numGlyphs = sis.readUI16(); for (int i = 0; i < numGlyphs; i++) { //offsetTable if (fontFlagsWideOffsets) { diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java index 35a4346c6..10ba87a7a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java @@ -95,7 +95,11 @@ public class DefineFontInfo2Tag extends Tag { SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); fontID = sis.readUI16(); int fontNameLen = sis.readUI8(); - fontName = new String(sis.readBytesEx(fontNameLen)); + if (version >= 6) { + fontName = new String(sis.readBytesEx(fontNameLen), Utf8Helper.charset); + } else { + fontName = new String(sis.readBytesEx(fontNameLen)); + } sis.readUB(2);//reserved fontFlagsSmallText = sis.readUB(1) == 1; fontFlagsShiftJIS = sis.readUB(1) == 1; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java index 4f3292d41..19996fbd7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java @@ -87,6 +87,7 @@ public class DefineFontInfoTag extends Tag { /** * Constructor * + * @param swf * @param data Data bytes * @param version SWF version * @param pos @@ -97,7 +98,11 @@ public class DefineFontInfoTag extends Tag { SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version); fontId = sis.readUI16(); int fontNameLen = sis.readUI8(); - fontName = new String(sis.readBytesEx(fontNameLen)); + if (version >= 6) { + fontName = new String(sis.readBytesEx(fontNameLen), Utf8Helper.charset); + } else { + fontName = new String(sis.readBytesEx(fontNameLen)); + } sis.readUB(2); //reserved fontFlagsSmallText = sis.readUB(1) == 1; fontFlagsShiftJIS = sis.readUB(1) == 1;