diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyCharKerning.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyCharKerning.java index 28041216e..386adfc70 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyCharKerning.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/IggyCharKerning.java @@ -16,6 +16,22 @@ public class IggyCharKerning implements StructureInterface { List kerningOffsets; long pad; + public long getKernCount() { + return kernCount; + } + + public List getCharsA() { + return charsA; + } + + public List getCharsB() { + return charsB; + } + + public List getKerningOffsets() { + return kerningOffsets; + } + public IggyCharKerning(AbstractDataStream stream, long kernCount) throws IOException { this.kernCount = kernCount; readFromDataStream(stream); 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 c695f8d21..2e9eb4fc6 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 @@ -22,8 +22,12 @@ public class IggyFont implements StructureInterface { byte[] zeroone; // stejny pro rozdilne fonty @IggyFieldType(DataType.uint16_t) int char_count2; - @IggyArrayFieldType(value = DataType.uint16_t, count = 3) - int[] what_1; + @IggyFieldType(value = DataType.uint16_t) + int ascent; + @IggyFieldType(value = DataType.uint16_t) + int descent; + @IggyFieldType(value = DataType.uint16_t) + int leading; @IggyFieldType(DataType.uint64_t) long flags; @IggyFieldType(DataType.uint64_t) @@ -87,19 +91,21 @@ public class IggyFont implements StructureInterface { String name; List charOffsets; - List chars; - IggyCharIndices charIndices; + List glyphs; + IggyCharIndices codePoints; IggyCharScales charScales; IggyCharKerning charKernings; byte[] padTo4byteBoundary; - public IggyFont(int type, int order_in_iggy_file, byte[] zeroone, int char_count2, int[] what_1, long flags, long start_of_char_struct, long start_of_char_index, long start_of_scale, long kern_count, float[] unk_float, long start_of_kern, long zero_padd, long what_2, long zero_padd_2, long start_of_name, long one_padd, int xscale, int yscale, long zero_padd_3, float ssr1, float ssr2, long char_count, long zero_padd_4, long what_3, byte[] zeroes, float sss1, long one_padd2, float sss2, long one_padd3, float sss3, long one_padd4, float sss4, long one_padd5, String name, List charOffsets, List chars, IggyCharIndices charIndices, IggyCharScales charScales, IggyCharKerning charKernings, byte[] padTo4byteBoundary) { + public IggyFont(int type, int order_in_iggy_file, byte[] zeroone, int char_count2, int ascent, int descent, int leading, long flags, long start_of_char_struct, long start_of_char_index, long start_of_scale, long kern_count, float[] unk_float, long start_of_kern, long zero_padd, long what_2, long zero_padd_2, long start_of_name, long one_padd, int xscale, int yscale, long zero_padd_3, float ssr1, float ssr2, long char_count, long zero_padd_4, long what_3, byte[] zeroes, float sss1, long one_padd2, float sss2, long one_padd3, float sss3, long one_padd4, float sss4, long one_padd5, String name, List charOffsets, List chars, IggyCharIndices charIndices, IggyCharScales charScales, IggyCharKerning charKernings, byte[] padTo4byteBoundary) { this.type = type; this.fontId = order_in_iggy_file; this.zeroone = zeroone; this.char_count2 = char_count2; - this.what_1 = what_1; + this.ascent = ascent; + this.descent = descent; + this.leading = leading; this.flags = flags; this.start_of_char_struct = start_of_char_struct; this.start_of_char_index = start_of_char_index; @@ -131,8 +137,8 @@ public class IggyFont implements StructureInterface { this.one_padd5 = one_padd5; this.name = name; this.charOffsets = charOffsets; - this.chars = chars; - this.charIndices = charIndices; + this.glyphs = chars; + this.codePoints = charIndices; this.charScales = charScales; this.charKernings = charKernings; this.padTo4byteBoundary = padTo4byteBoundary; @@ -157,10 +163,9 @@ public class IggyFont implements StructureInterface { fontId = s.readUI16(); zeroone = s.readBytes(28); char_count2 = s.readUI16(); - what_1 = new int[3]; - for (int i = 0; i < what_1.length; i++) { - what_1[i] = s.readUI16(); - } + ascent = s.readUI16(); + descent = s.readUI16(); + leading = s.readUI16(); flags = s.readUI64(); start_of_char_struct = readAbsoluteOffset(s); start_of_char_index = readAbsoluteOffset(s); @@ -215,20 +220,20 @@ public class IggyFont implements StructureInterface { for (int i = 0; i < char_count; i++) { charOffsets.add(new IggyCharOffset(s)); } - chars = new ArrayList<>(); + glyphs = new ArrayList<>(); for (int i = 0; i < char_count; i++) { long offset = charOffsets.get(i).offset; if (offset > 0) { - chars.add(new IggyChar(s, offset)); + glyphs.add(new IggyChar(s, offset)); } else { s.seek(1, SeekMode.CUR); - chars.add(null); + glyphs.add(null); } } } if (start_of_char_index != 0) { s.seek(start_of_char_index, SeekMode.SET); - charIndices = new IggyCharIndices(s, char_count); + codePoints = new IggyCharIndices(s, char_count); } if (start_of_scale != 0) { s.seek(start_of_scale, SeekMode.SET); @@ -270,11 +275,11 @@ public class IggyFont implements StructureInterface { } public List getChars() { - return chars; + return glyphs; } public IggyCharIndices getCharIndices() { - return charIndices; + return codePoints; } public IggyCharScales getCharScales() { @@ -285,4 +290,28 @@ public class IggyFont implements StructureInterface { return charKernings; } + public float[] getUnk_float() { + return unk_float; + } + + public int getAscent() { + return ascent; + } + + public int getDescent() { + return descent; + } + + public int getLeading() { + return leading; + } + + public long getWhat_2() { + return what_2; + } + + public long getWhat_3() { + return what_3; + } + } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/conversion/IggyCharToShapeConvertor.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/conversion/IggyCharToShapeConvertor.java index 07cdc5d01..4d473e9d3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/conversion/IggyCharToShapeConvertor.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/conversion/IggyCharToShapeConvertor.java @@ -24,11 +24,11 @@ import java.util.List; public class IggyCharToShapeConvertor { private static int convertDistanceX(double val) { - return (int) (20.0 * val * 1024.0); + return (int) (val * 1024.0); } private static int convertDistanceY(double val) { - return (int) (20.0 * val * 1024.0); + return (int) (val * 1024.0); } public static SHAPE convertCharToShape(IggyChar igchar) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/conversion/IggyToSwfConvertor.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/conversion/IggyToSwfConvertor.java index 98c9e4641..6017db9c8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/conversion/IggyToSwfConvertor.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/iggy/conversion/IggyToSwfConvertor.java @@ -3,6 +3,8 @@ package com.jpexs.decompiler.flash.iggy.conversion; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFCompression; import com.jpexs.decompiler.flash.iggy.IggyChar; +import com.jpexs.decompiler.flash.iggy.IggyCharKerning; +import com.jpexs.decompiler.flash.iggy.IggyCharOffset; import com.jpexs.decompiler.flash.iggy.IggyFile; import com.jpexs.decompiler.flash.iggy.IggyFont; import com.jpexs.decompiler.flash.iggy.IggyText; @@ -10,14 +12,18 @@ import com.jpexs.decompiler.flash.tags.DefineEditTextTag; import com.jpexs.decompiler.flash.tags.DefineFont2Tag; import com.jpexs.decompiler.flash.tags.EndTag; import com.jpexs.decompiler.flash.tags.FileAttributesTag; +import com.jpexs.decompiler.flash.types.KERNINGRECORD; import com.jpexs.decompiler.flash.types.RECT; +import com.jpexs.decompiler.flash.types.RGBA; import com.jpexs.decompiler.flash.types.SHAPE; +import java.awt.Color; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; @@ -60,6 +66,10 @@ public class IggyToSwfConvertor { swf.saveTo(output); } + private static int makeLengthsCorrect(double val) { + return (int) (SWF.unitDivisor * val); + } + public static SWF getSwf(IggyFile file, int swfIndex) { SWF swf = new SWF(); swf.compression = SWFCompression.NONE; @@ -90,6 +100,40 @@ public class IggyToSwfConvertor { currentCharId++; fontIndex2CharId.put(fontIndex, currentCharId); fontTag.fontID = currentCharId; + System.out.println("==================="); + System.out.println("xscale: " + iggyFont.getXscale()); //80 + System.out.println("yscale: " + iggyFont.getYscale()); //19 + + System.out.println("unk_float1: " + iggyFont.getUnk_float()[0]); + System.out.println("unk_float2: " + iggyFont.getUnk_float()[1]); + System.out.println("unk_float3: " + iggyFont.getUnk_float()[2]); + System.out.println("unk_float4: " + iggyFont.getUnk_float()[3]); + System.out.println("unk_float5: " + iggyFont.getUnk_float()[4]); + System.out.println("what_2: " + iggyFont.getWhat_2()); + System.out.println("what_3: " + iggyFont.getWhat_3()); + + /*List offsets = iggyFont.getc(); + fontTag.fontAdvanceTable = new ArrayList<>(); + for (int i = 0; i < offsets.size(); i++) { + fontTag.fontAdvanceTable.add((int) offsets.get(i).getOffset()); + }*/ + //FIXME + IggyCharKerning ker = iggyFont.getCharKernings(); + if (ker != null) { + fontTag.fontKerningTable = new ArrayList<>(); + for (int i = 0; i < ker.getKernCount(); i++) { + int kerningCode1 = ker.getCharsA().get(i); + int kerningCode2 = ker.getCharsA().get(i); + int kerningOffset = ker.getKerningOffsets().get(i); + fontTag.fontKerningTable.add(new KERNINGRECORD(kerningCode1, kerningCode2, kerningOffset)); + } + } + + fontTag.fontFlagsWideCodes = true; + fontTag.fontFlagsWideOffsets = true; + fontTag.fontAscent = iggyFont.getAscent(); + fontTag.fontDescent = iggyFont.getDescent(); + fontTag.fontLeading = iggyFont.getLeading(); fontTag.codeTable = new ArrayList<>(); fontTag.fontName = iggyFont.getName(); fontTag.glyphShapeTable = new ArrayList<>(); @@ -123,7 +167,18 @@ public class IggyToSwfConvertor { textIndex2CharId.put(iggyText.getTextIndex(), currentCharId); textTag.characterID = currentCharId; textTag.hasText = true; - textTag.initialText = iggyText.getInitialText(); + textTag.initialText = "A";//iggyText.getInitialText(); + //textTag.html = true; + textTag.hasTextColor = true; + textTag.textColor = new RGBA(Color.black); + textTag.fontHeight = 20 * 40; //?? + textTag.readOnly = true; + textTag.bounds = new RECT( + makeLengthsCorrect(iggyText.getPar3()), + makeLengthsCorrect(iggyText.getPar1()), + makeLengthsCorrect(iggyText.getPar4()), + makeLengthsCorrect(iggyText.getPar2()) + ); //textTag.hasFont = true; //textTag.fontId = fontIndex2CharId.get(iggyText.getFontIndex()); textTag.setModified(true);