SwfTagData ISwfTagVisitor <ISwfStreamWriter, SwfTagData> .Visit(DefineText2Tag tag, ISwfStreamWriter writer) { writer.WriteUInt16(tag.CharacterID); writer.WriteRect(tag.TextBounds); writer.WriteMatrix(ref tag.TextMatrix); var glyphBitsCounter = new UnsignedBitsCount(0); var advanceBitsCounter = new SignedBitsCount(0); foreach (var textRecord in tag.TextRecords) { foreach (var glyph in textRecord.Glyphs) { glyphBitsCounter.AddValue(glyph.GlyphIndex); advanceBitsCounter.AddValue(glyph.GlyphAdvance); } } var glyphBits = glyphBitsCounter.GetBits(); var advanceBits = advanceBitsCounter.GetBits(); writer.WriteByte((byte)glyphBits); writer.WriteByte((byte)advanceBits); foreach (var textRecord in tag.TextRecords) { writer.WriteTextRecordRGBA(textRecord, glyphBits, advanceBits); writer.FlushBits(); } writer.FlushBits(); return(null); }
public void GetBitsTest() { var bits = new UnsignedBitsCount(0); bits.AddValue(127); bits.AddValue(260); bits.AddValue(15); bits.AddValue(514); Assert.AreEqual(10, bits.GetBits()); }
public void GetBitsOneTest() { var bits = new UnsignedBitsCount(1); Assert.AreEqual(1, bits.GetBits()); }
public void GetBitsTwoTest() { var bits = new UnsignedBitsCount(2); Assert.AreEqual(2, bits.GetBits()); }
public void GetBitsZeroTest() { var bits = new UnsignedBitsCount(0); Assert.AreEqual(0, bits.GetBits()); }