public static DefineTextTag parse(final RecordHeader header, final SWFBinaryParser parser) throws SWFParserException {
final UINT16 characterId = parseUINT16(parser, 0x00006, "DefineText::CharacterId");
final Rect textBounds = RectParser.parse(parser, "DefineText::TextBounds");
final Matrix textMatrix = MatrixParser.parse(parser, "DefineText::TextMatrix");
final UINT8 glyphBits = parseUINT8(parser, 0x00006, "DefineText::GlyphBits");
final UINT8 advanceBits = parseUINT8(parser, 0x00006, "DefineText::AdvanceBits");
final List<TextRecord> textRecords = new ArrayList<TextRecord>();
do {
if (parser.peekUInt8().value() == 0) {
break;
}
textRecords.add(TextRecordParser.parse(parser, glyphBits.value(), advanceBits.value(), String.format("DefineText::TextRecords[%d]", textRecords.size())));
} while (true);
final UINT8 end = parseUINT8(parser, 0x00006, "DefineTextParser::EndOfRecordsFlag");
return new DefineTextTag(header, characterId, textBounds, textMatrix, glyphBits, advanceBits, new TextRecordList(textRecords), end);
}