if (!textRecordType)
return null;
bitStream.readUB(3); // reserved
final TextRecord textRecord = new TextRecord();
textRecord.setStyleFlagsHasFont(bitStream.readBit());
textRecord.setStyleFlagsHasColor(bitStream.readBit());
textRecord.setStyleFlagsHasYOffset(bitStream.readBit());
textRecord.setStyleFlagsHasXOffset(bitStream.readBit());
if (textRecord.isStyleFlagsHasFont())
{
final int fontId = bitStream.readUI16();
final ICharacterTag fontTag = getTagById(fontId, type);
textRecord.setFontTag(fontTag);
}
if (textRecord.isStyleFlagsHasColor())
{
if (type == TagType.DefineText2)
{
textRecord.setTextColor(readRGBA());
}
else
{
textRecord.setTextColor(readRGB());
}
}
if (textRecord.isStyleFlagsHasXOffset())
{
textRecord.setxOffset(bitStream.readSI16());
}
if (textRecord.isStyleFlagsHasYOffset())
{
textRecord.setyOffset(bitStream.readSI16());
}
if (textRecord.isStyleFlagsHasFont())
{
textRecord.setTextHeight(bitStream.readUI16());
}
textRecord.setGlyphCount(bitStream.readUI8());
final GlyphEntry[] glyphEntries = new GlyphEntry[textRecord.getGlyphCount()];
for (int i = 0; i < textRecord.getGlyphCount(); i++)
{
glyphEntries[i] = readGlyphEntry(glyphBits, advanceBits);
}
textRecord.setGlyphEntries(glyphEntries);
return textRecord;
}