/* DO NOT EDIT THIS FILE */
/* This file is autogenerated by the text-database code generator */

#ifndef CACHEDFONT_HPP
#define CACHEDFONT_HPP

#include <fonts/GeneratedFont.hpp>
#include <fonts/FontCache.hpp>

namespace touchgfx
{
class CachedFont : public GeneratedFont
{
public:
    CachedFont(const struct touchgfx::BinaryFontData* data, FontId id, FontCache* _cache, const GeneratedFont* _flashFont)
        : GeneratedFont((const GlyphNode*)((const uint8_t*)data + data->offsetToTable),
                        data->numberOfGlyphs,
                        data->height,
                        data->pixBelowBase,
                        data->bitsPerPixel,
                        data->dataFormatA4,
                        data->maxLeft,
                        data->maxRight,
                        0, //glyphDataPointer
                        0, //Kerning table not used for cached font
                        data->fallbackChar,
                        data->ellipsisChar,
                        0), //gsubTablePointer
          fontId(id),
          cache(_cache),
          flashFont(_flashFont)
    {}

    CachedFont() : GeneratedFont() {}

    using GeneratedFont::getGlyph;

    virtual const GlyphNode* getGlyph(Unicode::UnicodeChar unicode, const uint8_t*& pixelData, uint8_t& bitsPerPixel) const;

    virtual const uint8_t* getPixelData(const GlyphNode* glyph) const;

    virtual int8_t getKerning(Unicode::UnicodeChar prevChar, const GlyphNode* glyph) const;

    void setFontCache(FontCache& cache);
    FontId getFontId() const
    {
        return fontId;
    }

    virtual const uint16_t* getGSUBTable() const
    {
        if (gsubTable != 0)
        {
            return gsubTable;
        }
        return flashFont->getGSUBTable();
    }

    virtual void setGSUBTable(const uint16_t* table)
    {
        gsubTable = table;
    }

private:
    FontId fontId;
    FontCache* cache;
    const GeneratedFont* flashFont;
};
} // namespace touchgfx

#endif // CACHEDFONT_HPP
