from TypedText.hpp:52
class TypedText
{
public:
struct TypedTextData
{
const unsigned char fontIdx;
const Alignment alignment : 2;
const TextDirection direction : 2;
};
explicit TypedText(const TypedTextId id = TYPED_TEXT_INVALID) : typedTextId(id)
{
}
TypedTextId getId() const
{
return typedTextId;
}
bool hasValidId() const
{
return typedTextId != TYPED_TEXT_INVALID;
}
const Unicode::UnicodeChar* getText() const
{
assertValid();
return texts->getText(typedTextId);
}
const Font* getFont() const
{
assertValid();
return fonts[typedTexts[typedTextId].fontIdx];
}
Alignment getAlignment() const
{
assertValid();
return typedTexts[typedTextId].alignment;
}
TextDirection getTextDirection() const
{
assertValid();
return typedTexts[typedTextId].direction;
}
static void registerTypedTextDatabase(const TypedTextData* data, const Font* const* f, const uint16_t n)
{
typedTexts = data;
fonts = f;
numberOfTypedTexts = n;
}
static void registerTexts(const Texts* t)
{
texts = t;
}
private:
void assertValid() const
{
assert(typedTexts != 0 && "TypedText database has not been initialized.");
assert(typedTextId < numberOfTypedTexts && "typedTextId larger than numberOfTypedTexts.");
}
TypedTextId typedTextId;
static const TypedTextData* typedTexts;
static const Texts* texts;
static const Font* const* fonts;
static uint16_t numberOfTypedTexts;
};