From 91dabac158cda89e260ce1af49b9dc48c81343b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 3 Dec 2016 09:22:03 +0100 Subject: [PATCH] advances fix --- .../flash/iggy/IggyCharAdvances.java | 18 ++++++++++++------ .../jpexs/decompiler/flash/iggy/IggyFont.java | 5 +++-- .../jpexs/decompiler/flash/iggy/IggySwf.java | 13 ++++++++++--- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyCharAdvances.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyCharAdvances.java index 537e6be3b..628c4dd1f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyCharAdvances.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyCharAdvances.java @@ -14,29 +14,35 @@ import java.util.List; public class IggyCharAdvances implements StructureInterface { List advances; - private long charCount; + private List glyphs; public List getScales() { return advances; } - public IggyCharAdvances(ReadDataStreamInterface stream, long charCount) throws IOException { - this.charCount = charCount; + public IggyCharAdvances(ReadDataStreamInterface stream, List glyphs) throws IOException { + this.glyphs = glyphs; readFromDataStream(stream); } @Override public void readFromDataStream(ReadDataStreamInterface stream) throws IOException { advances = new ArrayList<>(); - for (int i = 0; i < charCount; i++) { - advances.add(stream.readFloat()); + for (int i = 0; i < glyphs.size(); i++) { + if (glyphs.get(i) != null) { + advances.add(stream.readFloat()); + } else { + advances.add(null); + } } } @Override public void writeToDataStream(WriteDataStreamInterface stream) throws IOException { for (int i = 0; i < advances.size(); i++) { - stream.writeFloat(advances.get(i)); + if (advances.get(i) != null) { + stream.writeFloat(advances.get(i)); + } } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyFont.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyFont.java index d1b39c06d..0f175d5d2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyFont.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyFont.java @@ -285,7 +285,7 @@ public class IggyFont extends IggyTag { } if (abs_start_of_scale != 0) { s.seek(abs_start_of_scale, SeekMode.SET); - charScales = new IggyCharAdvances(s, char_count); + charScales = new IggyCharAdvances(s, glyphs); } if (abs_start_of_kern != 0) { s.seek(abs_start_of_kern, SeekMode.SET); @@ -366,14 +366,15 @@ public class IggyFont extends IggyTag { s.writeUI64(0); //pad zero if (abs_start_of_char_struct != 0) { s.seek(abs_start_of_char_struct, SeekMode.SET); + long baseOfsAddr = s.position(); //offsets of shapes for (IggyCharOffset ofs : charOffsets) { ofs.writeToDataStream(s); } + //long afterOfsAddr = s.position(); for (int i = 0; i < glyphs.size(); i++) { IggyShape shp = glyphs.get(i); if (shp != null) { - s.seek(charOffsets.get(i).getAddress(), SeekMode.SET); shp.writeToDataStream(s); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggySwf.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggySwf.java index 279145d34..1905eebad 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggySwf.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggySwf.java @@ -62,7 +62,11 @@ public class IggySwf implements StructureInterface { newData = stream.getAllBytes(); newLen = newData.length; } - long oldLen = font_data_sizes[fontIndex]; + + //FIXME + Helper.writeFile("d:\\Dropbox\\jpexs-laptop\\iggi\\extraxtdir_new\\font" + fontIndex + ".bin", newData); + + /* long oldLen = font_data_sizes[fontIndex]; long diff = newLen - oldLen; if (diff != 0) { font_data_sizes[fontIndex] = newLen; @@ -77,7 +81,7 @@ public class IggySwf implements StructureInterface { } } hdr.insertGapAfter(font_data_addresses[fontIndex], diff); - + */ } @Override @@ -154,7 +158,10 @@ public class IggySwf implements StructureInterface { fonts = new HashMap<>(); for (int i = 0; i < hdr.font_count; i++) { s.seek(font_data_addresses[i], SeekMode.SET); - //byte font_data[] = s.readBytes((int) font_data_sizes[i]); + byte font_data[] = s.readBytes((int) font_data_sizes[i]); + //FIXME + Helper.writeFile("d:\\Dropbox\\jpexs-laptop\\iggi\\extraxtdir_orig\\font" + i + ".bin", font_data); + s.seek(-font_data_sizes[i], SeekMode.CUR); IggyFont font = new IggyFont(s); fonts.put(i, font); }