Exemplo n.º 1
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.Jump);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendInt16(BranchOffset);
        }
Exemplo n.º 2
0
        public void ToSwf(SwfWriter w)
        {
            w.AppendByte((byte)ActionKind.If);
            w.AppendUI16(Length - 3); // don't incude def byte and len

            w.AppendInt16(BranchOffset);
        }
Exemplo n.º 3
0
        public void ToSwf(SwfWriter w, uint glyphBits, uint advanceBits, bool hasAlpha)
        {
            w.AppendBit(TextRecordType);
            w.AppendBits(StyleFlagsReserved, 3);
            w.AppendBit(StyleFlagsHasFont);
            w.AppendBit(StyleFlagsHasColor);
            w.AppendBit(StyleFlagsHasYOffset);
            w.AppendBit(StyleFlagsHasXOffset);
            w.Align();

            if (StyleFlagsHasFont)
            {
                w.AppendUI16(FontID);
            }
            if (StyleFlagsHasColor)
            {
                w.AppendByte(TextColor.R);
                w.AppendByte(TextColor.G);
                w.AppendByte(TextColor.B);
                if (hasAlpha)
                {
                    w.AppendByte(TextColor.A);
                }
            }
            if (StyleFlagsHasXOffset)
            {
                w.AppendInt16(XOffset);
            }
            if (StyleFlagsHasYOffset)
            {
                w.AppendInt16(YOffset);
            }
            if (StyleFlagsHasFont)
            {
                w.AppendUI16(TextHeight);
            }

            w.AppendByte((byte)GlyphEntries.Length);

            for (int i = 0; i < GlyphEntries.Length; i++)
            {
                w.AppendBits(GlyphEntries[i].GlyphIndex, glyphBits);
                w.AppendSignedNBits(GlyphEntries[i].GlyphAdvance, advanceBits);
            }
            w.Align();
        }
Exemplo n.º 4
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;

            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(FontId);

            w.AppendBit(FontFlagsHasLayout);
            w.AppendBit(FontFlagsShiftJIS);
            w.AppendBit(FontFlagsSmallText);
            w.AppendBit(FontFlagsANSI);
            w.AppendBit(FontFlagsWideOffsets);
            w.AppendBit(FontFlagsWideCodes);
            w.AppendBit(FontFlagsItalic);
            w.AppendBit(FontFlagsBold);
            w.Align();

            w.AppendByte((byte)LanguageCode);
            w.AppendByte((byte)(FontName.Length + 1)); // add trailing /0
            w.AppendString(FontName, (uint)FontName.Length);

            w.AppendUI16(NumGlyphs);
            for (int i = 0; i < this.NumGlyphs; i++)
            {
                if (this.FontFlagsWideOffsets)
                {
                    w.AppendUI32(this.OffsetTable[i]);
                }
                else
                {
                    w.AppendUI16(this.OffsetTable[i]);
                }
            }


            if (this.FontFlagsWideOffsets)
            {
                w.AppendUI32(this.CodeTableOffset);
            }
            else
            {
                w.AppendUI16(this.CodeTableOffset);
            }

            for (int i = 0; i < this.NumGlyphs; i++)
            {
                GlyphShapeTable[i].ToSwf(w);
            }

            for (int i = 0; i < this.NumGlyphs; i++)
            {
                w.AppendUI16(this.CodeTable[i]);
            }

            if (this.FontFlagsHasLayout)
            {
                w.AppendInt16(FontAscent);
                w.AppendInt16(FontDescent);
                w.AppendInt16(FontLeading);

                for (int i = 0; i < this.NumGlyphs; i++)
                {
                    w.AppendInt16(this.FontAdvanceTable[i]);
                }

                for (int i = 0; i < this.NumGlyphs; i++)
                {
                    this.FontBoundsTable[i].ToSwf(w);
                }

                w.AppendUI16(this.KerningCount);

                if (this.FontFlagsWideCodes)
                {
                    for (int i = 0; i < this.KerningCount; i++)
                    {
                        w.AppendUI16(this.FontKerningTable[i].FontKerningCode1);
                        w.AppendUI16(this.FontKerningTable[i].FontKerningCode2);
                        w.AppendInt16(this.FontKerningTable[i].FontKerningAdjustment);
                    }
                }
                else
                {
                    for (int i = 0; i < this.KerningCount; i++)
                    {
                        w.AppendByte((byte)this.FontKerningTable[i].FontKerningCode1);
                        w.AppendByte((byte)this.FontKerningTable[i].FontKerningCode2);
                        w.AppendInt16(this.FontKerningTable[i].FontKerningAdjustment);
                    }
                }
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Exemplo n.º 5
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.GotoFrame);
     w.AppendUI16(Length - 3);// don't incude this part
     w.AppendInt16(Frame);
 }
Exemplo n.º 6
0
 public void ToSwf(SwfWriter w)
 {
     w.AppendByte((byte)ActionKind.GotoFrame);
     w.AppendUI16(Length - 3);// don't incude this part
     w.AppendInt16(Frame);
 }
Exemplo n.º 7
0
        public void ToSwf(SwfWriter w)
        {
            uint start = (uint)w.Position;
            w.AppendTagIDAndLength(this.TagType, 0, true);

            w.AppendUI16(FontId);

            w.AppendBit(FontFlagsHasLayout);
            w.AppendBit(FontFlagsShiftJIS);
            w.AppendBit(FontFlagsSmallText);
            w.AppendBit(FontFlagsANSI);
            w.AppendBit(FontFlagsWideOffsets);
            w.AppendBit(FontFlagsWideCodes);
            w.AppendBit(FontFlagsItalic);
            w.AppendBit(FontFlagsBold);
            w.Align();

            w.AppendByte((byte)LanguageCode);
            w.AppendByte((byte)(FontName.Length + 1)); // add trailing /0
            w.AppendString(FontName, (uint)FontName.Length);

            w.AppendUI16(NumGlyphs);
            for (int i = 0; i < this.NumGlyphs; i++)
            {
                if (this.FontFlagsWideOffsets)
                {
                    w.AppendUI32(this.OffsetTable[i]);
                }
                else
                {
                    w.AppendUI16(this.OffsetTable[i]);
                }
            }

            if (this.FontFlagsWideOffsets)
            {
                w.AppendUI32(this.CodeTableOffset);
            }
            else
            {
                w.AppendUI16(this.CodeTableOffset);
            }

            for (int i = 0; i < this.NumGlyphs; i++)
            {
                GlyphShapeTable[i].ToSwf(w);
            }

            for (int i = 0; i < this.NumGlyphs; i++)
            {
                w.AppendUI16(this.CodeTable[i]);
            }

            if (this.FontFlagsHasLayout)
            {
                w.AppendInt16(FontAscent);
                w.AppendInt16(FontDescent);
                w.AppendInt16(FontLeading);

                for (int i = 0; i < this.NumGlyphs; i++)
                {
                    w.AppendInt16(this.FontAdvanceTable[i]);
                }

                for (int i = 0; i < this.NumGlyphs; i++)
                {
                    this.FontBoundsTable[i].ToSwf(w);
                }

                w.AppendUI16(this.KerningCount);

                if(this.FontFlagsWideCodes)
                {
                    for (int i = 0; i < this.KerningCount; i++)
                    {
                        w.AppendUI16(this.FontKerningTable[i].FontKerningCode1);
                        w.AppendUI16(this.FontKerningTable[i].FontKerningCode2);
                        w.AppendInt16(this.FontKerningTable[i].FontKerningAdjustment);
                    }
                }
                else
                {
                    for (int i = 0; i < this.KerningCount; i++)
                    {
                        w.AppendByte((byte)this.FontKerningTable[i].FontKerningCode1);
                        w.AppendByte((byte)this.FontKerningTable[i].FontKerningCode2);
                        w.AppendInt16(this.FontKerningTable[i].FontKerningAdjustment);
                    }
                }
            }

            w.ResetLongTagLength(this.TagType, start, true);
        }
Exemplo n.º 8
0
        public void ToSwf(SwfWriter w, uint glyphBits, uint advanceBits, bool hasAlpha)
        {
            w.AppendBit(TextRecordType);
            w.AppendBits(StyleFlagsReserved, 3);
            w.AppendBit(StyleFlagsHasFont);
            w.AppendBit(StyleFlagsHasColor);
            w.AppendBit(StyleFlagsHasYOffset);
            w.AppendBit(StyleFlagsHasXOffset);
            w.Align();

            if (StyleFlagsHasFont)
            {
                w.AppendUI16(FontID);
            }
            if (StyleFlagsHasColor)
            {
                w.AppendByte(TextColor.R);
                w.AppendByte(TextColor.G);
                w.AppendByte(TextColor.B);
                if (hasAlpha)
                {
                    w.AppendByte(TextColor.A);
                }
            }
            if (StyleFlagsHasXOffset)
            {
                w.AppendInt16(XOffset);
            }
            if (StyleFlagsHasYOffset)
            {
                w.AppendInt16(YOffset);
            }
            if (StyleFlagsHasFont)
            {
                w.AppendUI16(TextHeight);
            }

            w.AppendByte((byte)GlyphEntries.Length);

            for (int i = 0; i < GlyphEntries.Length; i++)
            {
                w.AppendBits(GlyphEntries[i].GlyphIndex, glyphBits);
                w.AppendSignedNBits(GlyphEntries[i].GlyphAdvance, advanceBits);
            }
            w.Align();
        }