partial fix for #649

This commit is contained in:
honfika
2014-08-24 08:41:31 +02:00
parent e2bfb41546
commit e453fabfca
5 changed files with 34 additions and 10 deletions
@@ -17,7 +17,6 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.Deobfuscation;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
@@ -39,6 +39,7 @@ import com.jpexs.decompiler.flash.types.shaperecords.StraightEdgeRecord;
import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.MemoryInputStream;
import java.awt.Font;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -94,8 +95,9 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag {
fontId = sis.readUI16("fontId");
fonts = new ArrayList<>();
while (sis.available() > 0) {
fonts.add(new FontType(new GFxInputStream(sis.getBaseStream())));
MemoryInputStream mis = sis.getBaseStream();
while (mis.available() > 0) {
fonts.add(new FontType(new GFxInputStream(mis)));
}
rebuildShapeCache();
}
@@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.types.gfx.GFxInputStream;
import com.jpexs.decompiler.flash.types.gfx.GFxOutputStream;
import com.jpexs.decompiler.flash.types.gfx.TEXGLYPH;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.MemoryInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -101,13 +102,19 @@ public class FontTextureInfo extends Tag {
nominalGlyphSz = sis.readUI16("nominalGlyphSz");
int numTexGlyphs = sis.readUI16("numTexGlyphs");
texGlyphs = new TEXGLYPH[numTexGlyphs];
MemoryInputStream mis = sis.getBaseStream();
for (int i = 0; i < numTexGlyphs; i++) {
texGlyphs[i] = new TEXGLYPH(new GFxInputStream(sis.getBaseStream()));
texGlyphs[i] = new TEXGLYPH(new GFxInputStream(mis));
}
// todo: honfika: add GFx data to dump view
sis.skipBytes(mis.getPos());
int numFonts = sis.readUI16("numFonts");
fonts = new FONTINFO[numFonts];
mis = sis.getBaseStream();
for (int i = 0; i < numFonts; i++) {
fonts[i] = new FONTINFO(new GFxInputStream(sis.getBaseStream()));
}
// todo: honfika: add GFx data to dump view
sis.skipBytes(mis.getPos());
}
}
@@ -42,12 +42,7 @@ public class FontType implements Serializable {
public List<KerningPairType> kerning;
public FontType(GFxInputStream sis) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int val;
while ((val = sis.readUI8()) > 0) {
baos.write(val);
}
fontName = new String(baos.toByteArray());
fontName = sis.readString();
flags = sis.readUI16();
nominalSize = sis.readUI16();
ascent = sis.readSI16();
@@ -17,6 +17,8 @@
package com.jpexs.decompiler.flash.types.gfx;
import com.jpexs.helpers.MemoryInputStream;
import com.jpexs.helpers.utf8.Utf8Helper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
/**
@@ -161,4 +163,23 @@ public class GFxInputStream {
void read(byte[] bytes) throws IOException {
is.read(bytes);
}
/**
* Reads one string value from the stream
*
* @param name
* @return String value
* @throws IOException
*/
public String readString() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int r;
while (true) {
r = readUI8();
if (r == 0) {
return new String(baos.toByteArray(), Utf8Helper.charset);
}
baos.write(r);
}
}
}