Exemple #1
0
        protected override void DecompileBody(byte[] data)
        {
            SwfStream stream = data;
            short     count  = stream.ReadShort();

            TagArray  = new short[count];
            NameArray = new string[count];
            for (int i = 0; i < count; i++)
            {
                TagArray[i]  = stream.ReadShort();
                NameArray[i] = stream.ReadString();
            }
        }
Exemple #2
0
        public TextRecord(SwfStream stream, bool hasAlpha, int glyphBits, int advanceBits)
        {
            _flags = stream.ReadByte();
            if (EndRecord) return;

            if (HasFont) FontId = stream.ReadUShort();
            if (HasColor) Color = hasAlpha ? stream.ReadRGBA() : stream.ReadRGB();
            if (HasXOffset) XOffset = stream.ReadShort();
            if (HasYOffset) YOffset = stream.ReadShort();
            if (HasFont) FontSize = stream.ReadUShort();

            byte count = stream.ReadByte();
            Glyphs = new GlyphEntry[count];
            for (int i = 0; i < count; i++)
                Glyphs[i] = new GlyphEntry(stream, glyphBits, advanceBits);
        }
        protected override void DecompileBody(byte[] data)
        {
            SwfStream stream = data;

            Tag = stream.ReadShort();
            stream.ReadBytes(4);
            Data = stream.ReadToEnd();
        }
Exemple #4
0
 public virtual void Load(SwfStream stream, uint length, byte version)
 {
     CharacterID = stream.ReadUShort();
     Bounds = stream.ReadRectangle();
     Flags = (EditTextFlags)stream.ReadUShort();
     if ((Flags & EditTextFlags.HasFont) != 0) FontID = stream.ReadUShort();
     if ((Flags & EditTextFlags.HasFontClass) != 0) FontClass = stream.ReadString();
     if ((Flags & EditTextFlags.HasFont) != 0) FontHeight = stream.ReadUShort();
     TextColor = ((Flags & EditTextFlags.HasTextColor) != 0) ? stream.ReadRGBA() : (VGColor)Color.Black;
     MaxLength = ((Flags & EditTextFlags.HasMaxLength) != 0) ? stream.ReadUShort() : ushort.MaxValue;
     if ((Flags & EditTextFlags.HasLayout) != 0)
     {
         TextAlign = (Align)stream.ReadByte();
         LeftMargin = stream.ReadUShort();
         RightMargin = stream.ReadUShort();
         Indent = stream.ReadUShort();
         Leading = stream.ReadShort();
     }
     Variable = stream.ReadString();
     InitialText = ((Flags & EditTextFlags.HasText) != 0) ? stream.ReadString() : string.Empty;
 }
Exemple #5
0
        public virtual void Load(SwfStream stream, uint length, byte version)
        {
            CharacterID = stream.ReadUShort();
            Flags = (FontFlags)stream.ReadByte();
            Language = stream.ReadLanguage();
            Name = stream.ReadString(stream.ReadByte());
            ushort count = stream.ReadUShort();
            stream.Skip((count + 1) * (((Flags & FontFlags.WideOffsets) != 0) ? 4 : 2)); // Offsets

            Glyphs = new FontGlyph[count];
            for (int i = 0; i < count; i++)
            {
                var subShapes = new Shape(ShapeInfo.ReadShape(stream, false, false, false, false), true).SubShapes;
                if (subShapes == null || subShapes.Length < 1) continue;

                var shape = subShapes[0];
                if (shape != null && shape.Fills.Count > 0)
                {
                    Glyphs[i] = new FontGlyph
                    {
                        GlyphPath = shape.Fills.Values.First().GetPath(),
                        ReferencePoint = new Vector2(shape.Shape.ReferencePoint.X, shape.Shape.ReferencePoint.Y) * DefineFontTag.EMSquareInv
                    };
                    Glyphs[i].GlyphPath.Scale(DefineFontTag.EMSquareInv);
                }
                else
                    Glyphs[i] = new FontGlyph { GlyphPath = new VGPath(), ReferencePoint = Vector2.Zero };
            }

            if ((Flags & FontFlags.WideCodes) != 0)
                Characters = stream.ReadCharArray((int)count);
            else
            {
                Characters = new char[count];
                for (int i = 0; i < count; i++)
                    Characters[i] = (char)stream.ReadByte();
            }

            if ((Flags & FontFlags.HasLayout) != 0)
            {
                Ascent = stream.ReadShort();
                Descent = stream.ReadShort();
                Leading = stream.ReadShort();
                Advances = stream.ReadShortArray(count);
                Bounds = stream.ReadRectangleArray(count);

                char l, r;
                int adj;
                ushort kerns = stream.ReadUShort();
                Kerning = new VGKerningTable(kerns);
                if ((Flags & FontFlags.WideCodes) != 0)
                {
                    for (int i = 0; i < kerns; i++)
                    {
                        l = (char)stream.ReadUShort();
                        r = (char)stream.ReadUShort();
                        adj = stream.ReadShort();
                        Kerning.Add(l, r, adj);
                    }
                }
                else
                {
                    for (int i = 0; i < kerns; i++)
                    {
                        l = (char)stream.ReadByte();
                        r = (char)stream.ReadByte();
                        adj = stream.ReadShort();
                        Kerning.Add(l, r, adj);
                    }
                }
            }
        }