Issue #504: font name reading fixed

This commit is contained in:
Honfika
2014-02-06 18:03:45 +01:00
parent 99a6a85ff7
commit d68da494f0
4 changed files with 21 additions and 4 deletions

View File

@@ -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

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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;