Use TouchGFX
This commit is contained in:
		
							
								
								
									
										1
									
								
								TouchGFX/generated/fonts/UnicodeListverdana_10_4.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								TouchGFX/generated/fonts/UnicodeListverdana_10_4.txt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
63
 | 
			
		||||
							
								
								
									
										8
									
								
								TouchGFX/generated/fonts/UnicodeListverdana_20_4.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								TouchGFX/generated/fonts/UnicodeListverdana_20_4.txt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
			
		||||
63
 | 
			
		||||
66
 | 
			
		||||
70
 | 
			
		||||
83
 | 
			
		||||
84
 | 
			
		||||
85
 | 
			
		||||
97
 | 
			
		||||
101
 | 
			
		||||
							
								
								
									
										1
									
								
								TouchGFX/generated/fonts/UnicodeListverdana_40_4.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								TouchGFX/generated/fonts/UnicodeListverdana_40_4.txt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
63
 | 
			
		||||
							
								
								
									
										1
									
								
								TouchGFX/generated/fonts/cache/ApplicationFontProvider.cache
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								TouchGFX/generated/fonts/cache/ApplicationFontProvider.cache
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
{"typographies":[["Default","verdana.ttf",20,4],["Large","verdana.ttf",40,4],["Small","verdana.ttf",10,4]],"generate_font_format":"0"}
 | 
			
		||||
							
								
								
									
										1
									
								
								TouchGFX/generated/fonts/cache/ApplicationFontProviderHpp.cache
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								TouchGFX/generated/fonts/cache/ApplicationFontProviderHpp.cache
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
{"typographies":[["Default","verdana.ttf",20,4],["Large","verdana.ttf",40,4],["Small","verdana.ttf",10,4]],"generate_font_format":"0"}
 | 
			
		||||
							
								
								
									
										2
									
								
								TouchGFX/generated/fonts/cache/Font_verdana_10_4bppCpp.cache
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								TouchGFX/generated/fonts/cache/Font_verdana_10_4bppCpp.cache
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
			
		||||
AH:0 BA:1 FC:63 EC:0 FF:0 CF:1
 | 
			
		||||
63
 | 
			
		||||
							
								
								
									
										9
									
								
								TouchGFX/generated/fonts/cache/Font_verdana_20_4bppCpp.cache
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								TouchGFX/generated/fonts/cache/Font_verdana_20_4bppCpp.cache
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
			
		||||
AH:0 BA:1 FC:63 EC:0 FF:0 CF:0
 | 
			
		||||
63
 | 
			
		||||
66
 | 
			
		||||
70
 | 
			
		||||
83
 | 
			
		||||
84
 | 
			
		||||
85
 | 
			
		||||
97
 | 
			
		||||
101
 | 
			
		||||
							
								
								
									
										2
									
								
								TouchGFX/generated/fonts/cache/Font_verdana_40_4bppCpp.cache
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								TouchGFX/generated/fonts/cache/Font_verdana_40_4bppCpp.cache
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
			
		||||
AH:0 BA:1 FC:63 EC:0 FF:0 CF:0
 | 
			
		||||
63
 | 
			
		||||
@ -0,0 +1,44 @@
 | 
			
		||||
/* DO NOT EDIT THIS FILE */
 | 
			
		||||
/* This file is autogenerated by the text-database code generator */
 | 
			
		||||
 | 
			
		||||
#ifndef TOUCHGFX_APPLICATIONFONTPROVIDER_HPP
 | 
			
		||||
#define TOUCHGFX_APPLICATIONFONTPROVIDER_HPP
 | 
			
		||||
 | 
			
		||||
#include <touchgfx/FontManager.hpp>
 | 
			
		||||
 | 
			
		||||
namespace touchgfx
 | 
			
		||||
{
 | 
			
		||||
class FlashDataReader;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct Typography
 | 
			
		||||
{
 | 
			
		||||
    static const touchgfx::FontId DEFAULT = 0;
 | 
			
		||||
    static const touchgfx::FontId LARGE = 1;
 | 
			
		||||
    static const touchgfx::FontId SMALL = 2;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct TypographyFontIndex
 | 
			
		||||
{
 | 
			
		||||
    static const touchgfx::FontId DEFAULT = 0; // verdana_20_4bpp
 | 
			
		||||
    static const touchgfx::FontId LARGE = 1;   // verdana_40_4bpp
 | 
			
		||||
    static const touchgfx::FontId SMALL = 2;   // verdana_10_4bpp
 | 
			
		||||
    static const uint16_t NUMBER_OF_FONTS = 3;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class ApplicationFontProvider : public touchgfx::FontProvider
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    virtual touchgfx::Font* getFont(touchgfx::FontId typography);
 | 
			
		||||
 | 
			
		||||
    static void setFlashReader(touchgfx::FlashDataReader* /*flashReader*/)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static touchgfx::FlashDataReader* getFlashReader()
 | 
			
		||||
    {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // TOUCHGFX_APPLICATIONFONTPROVIDER_HPP
 | 
			
		||||
							
								
								
									
										92
									
								
								TouchGFX/generated/fonts/include/fonts/CachedFont.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								TouchGFX/generated/fonts/include/fonts/CachedFont.hpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,92 @@
 | 
			
		||||
/* DO NOT EDIT THIS FILE */
 | 
			
		||||
/* This file is autogenerated by the text-database code generator */
 | 
			
		||||
 | 
			
		||||
#ifndef TOUCHGFX_CACHEDFONT_HPP
 | 
			
		||||
#define TOUCHGFX_CACHEDFONT_HPP
 | 
			
		||||
 | 
			
		||||
#include <fonts/FontCache.hpp>
 | 
			
		||||
#include <fonts/GeneratedFont.hpp>
 | 
			
		||||
 | 
			
		||||
namespace touchgfx
 | 
			
		||||
{
 | 
			
		||||
class CachedFont : public GeneratedFont
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    CachedFont(const struct touchgfx::BinaryFontData* data, FontId id, FontCache* _cache, const GeneratedFont* _flashFont)
 | 
			
		||||
        : GeneratedFont(0, // GlyphNode*
 | 
			
		||||
                        data->numberOfGlyphs,
 | 
			
		||||
                        data->fontHeight,
 | 
			
		||||
                        data->baseline,
 | 
			
		||||
                        data->pixAboveTop,
 | 
			
		||||
                        data->pixBelowBottom,
 | 
			
		||||
                        data->bitsPerPixel,
 | 
			
		||||
                        data->byteAlignRow,
 | 
			
		||||
                        data->maxLeft,
 | 
			
		||||
                        data->maxRight,
 | 
			
		||||
                        0, // glyphDataPointer
 | 
			
		||||
                        0, // Kerning table not used for cached font
 | 
			
		||||
                        data->fallbackChar,
 | 
			
		||||
                        data->ellipsisChar,
 | 
			
		||||
                        0,  // lsubTablePointer
 | 
			
		||||
                        0), // contextualFormsPointer
 | 
			
		||||
          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;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual const FontContextualFormsTable* getContextualFormsTable() const
 | 
			
		||||
    {
 | 
			
		||||
        if (arabicTable != 0)
 | 
			
		||||
        {
 | 
			
		||||
            return arabicTable;
 | 
			
		||||
        }
 | 
			
		||||
        return flashFont->getContextualFormsTable();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual void setContextualFormsTable(const FontContextualFormsTable* table)
 | 
			
		||||
    {
 | 
			
		||||
        arabicTable = table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    FontId fontId;
 | 
			
		||||
    FontCache* cache;
 | 
			
		||||
    const GeneratedFont* flashFont;
 | 
			
		||||
};
 | 
			
		||||
} // namespace touchgfx
 | 
			
		||||
 | 
			
		||||
#endif // TOUCHGFX_CACHEDFONT_HPP
 | 
			
		||||
							
								
								
									
										96
									
								
								TouchGFX/generated/fonts/include/fonts/FontCache.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								TouchGFX/generated/fonts/include/fonts/FontCache.hpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,96 @@
 | 
			
		||||
/* DO NOT EDIT THIS FILE */
 | 
			
		||||
/* This file is autogenerated by the text-database code generator */
 | 
			
		||||
 | 
			
		||||
#ifndef TOUCHGFX_FONTCACHE_HPP
 | 
			
		||||
#define TOUCHGFX_FONTCACHE_HPP
 | 
			
		||||
 | 
			
		||||
#include <touchgfx/Font.hpp>
 | 
			
		||||
#include <touchgfx/TypedText.hpp>
 | 
			
		||||
#include <fonts/ApplicationFontProvider.hpp>
 | 
			
		||||
 | 
			
		||||
namespace touchgfx
 | 
			
		||||
{
 | 
			
		||||
class CachedFont;
 | 
			
		||||
 | 
			
		||||
class FontDataReader
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    virtual ~FontDataReader()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
    virtual void open() = 0;
 | 
			
		||||
    virtual void close() = 0;
 | 
			
		||||
    virtual void setPosition(uint32_t position) = 0;
 | 
			
		||||
    virtual void readData(void* out, uint32_t numberOfBytes) = 0;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class FontCache
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    FontCache();
 | 
			
		||||
    void setReader(FontDataReader* reader);
 | 
			
		||||
    void clear(bool keepGsubOrContextTable = false);
 | 
			
		||||
    void setMemory(uint8_t* memory, uint32_t size);
 | 
			
		||||
    void initializeCachedFont(TypedText t, CachedFont* font, bool loadGsubOrContextTable = false);
 | 
			
		||||
    bool cacheString(TypedText t, const Unicode::UnicodeChar* string);
 | 
			
		||||
    bool cacheLigatures(CachedFont* font, TypedText t, const Unicode::UnicodeChar* string);
 | 
			
		||||
 | 
			
		||||
    const GlyphNode* getGlyph(Unicode::UnicodeChar unicode, FontId font) const;
 | 
			
		||||
    uint32_t getMemoryUsage()
 | 
			
		||||
    {
 | 
			
		||||
        return memorySize - (gsubStart - top);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void open();
 | 
			
		||||
    void close();
 | 
			
		||||
 | 
			
		||||
    static inline const uint8_t* getPixelData(const GlyphNode* glyph)
 | 
			
		||||
    {
 | 
			
		||||
        return ((const uint8_t*)glyph) + SizeGlyphNode + 4;
 | 
			
		||||
    }
 | 
			
		||||
    static inline bool isCached(const GlyphNode* g)
 | 
			
		||||
    {
 | 
			
		||||
        return g->dataOffset == 0xFFFFFFFF;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    static const uint32_t SizeGlyphNode = 16;
 | 
			
		||||
 | 
			
		||||
    bool contains(Unicode::UnicodeChar unicode, FontId font) const;
 | 
			
		||||
    void insert(Unicode::UnicodeChar unicode, FontId font, uint32_t bpp, bool& outOfMemory);
 | 
			
		||||
    uint8_t* copyGlyph(uint8_t* top, Unicode::UnicodeChar unicode, FontId font, uint32_t bpp, bool& outOfMemory);
 | 
			
		||||
 | 
			
		||||
    void cacheData(uint32_t bpp, GlyphNode* first);
 | 
			
		||||
    bool cacheSortedString(TypedText t);
 | 
			
		||||
    bool createSortedString(const Unicode::UnicodeChar* string);
 | 
			
		||||
    bool createSortedLigatures(CachedFont* font, TypedText t, const Unicode::UnicodeChar* string, ...);
 | 
			
		||||
    bool sortSortedString(int n);
 | 
			
		||||
 | 
			
		||||
    void setPosition(uint32_t position);
 | 
			
		||||
    void readData(void* out, uint32_t numberOfBytes);
 | 
			
		||||
 | 
			
		||||
    struct
 | 
			
		||||
    {
 | 
			
		||||
        uint8_t* first; // First GlyphNode, glyph in cache;
 | 
			
		||||
        uint8_t* last;  // Last GlyphNode, glyph in cache;
 | 
			
		||||
    } fontTable[MAX(TypographyFontIndex::NUMBER_OF_FONTS, 1)];
 | 
			
		||||
 | 
			
		||||
    uint32_t memorySize;
 | 
			
		||||
    uint8_t* memory;    // Start of memory
 | 
			
		||||
    uint8_t* top;       // First unused byte
 | 
			
		||||
    uint8_t* gsubStart; // First address of GSUB tables, allocated in the end of the cache
 | 
			
		||||
 | 
			
		||||
    FontDataReader* reader;
 | 
			
		||||
 | 
			
		||||
    Unicode::UnicodeChar* sortedString;
 | 
			
		||||
    // Must be bigger than BinaryFontData
 | 
			
		||||
    static const uint32_t MAX_BUFFER_SIZE = 64;
 | 
			
		||||
    char buffer[MAX_BUFFER_SIZE];
 | 
			
		||||
    uint32_t glyphDataOffset;
 | 
			
		||||
    uint16_t numGlyphs;
 | 
			
		||||
    uint16_t currentFileGlyphNumber;
 | 
			
		||||
    GlyphNode currentFileGlyphNode;
 | 
			
		||||
};
 | 
			
		||||
} // namespace touchgfx
 | 
			
		||||
 | 
			
		||||
#endif // TOUCHGFX_FONTCACHE_HPP
 | 
			
		||||
							
								
								
									
										132
									
								
								TouchGFX/generated/fonts/include/fonts/GeneratedFont.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										132
									
								
								TouchGFX/generated/fonts/include/fonts/GeneratedFont.hpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,132 @@
 | 
			
		||||
/* DO NOT EDIT THIS FILE */
 | 
			
		||||
/* This file is autogenerated by the text-database code generator */
 | 
			
		||||
 | 
			
		||||
#ifndef TOUCHGFX_GENERATEDFONT_HPP
 | 
			
		||||
#define TOUCHGFX_GENERATEDFONT_HPP
 | 
			
		||||
 | 
			
		||||
#include <touchgfx/ConstFont.hpp>
 | 
			
		||||
 | 
			
		||||
namespace touchgfx
 | 
			
		||||
{
 | 
			
		||||
class GeneratedFont : public ConstFont
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    GeneratedFont(const GlyphNode* glyphs, uint16_t numGlyphs, uint16_t height, uint16_t baseline, uint8_t pixAboveTop, uint8_t pixBelowBottom, uint8_t bitsPerPixel, uint8_t byteAlignRow, uint8_t maxLeft, uint8_t maxRight, const uint8_t* const* glyphDataInternalFlash, const KerningNode* kerningList, const Unicode::UnicodeChar fallbackChar, const Unicode::UnicodeChar ellipsisChar, const uint16_t* const gsubData, const FontContextualFormsTable* formsTable);
 | 
			
		||||
 | 
			
		||||
    using ConstFont::getGlyph;
 | 
			
		||||
 | 
			
		||||
    virtual const uint8_t* getPixelData(const GlyphNode* glyph) const;
 | 
			
		||||
 | 
			
		||||
    virtual int8_t getKerning(Unicode::UnicodeChar prevChar, const GlyphNode* glyph) const;
 | 
			
		||||
 | 
			
		||||
    virtual const uint16_t* getGSUBTable() const
 | 
			
		||||
    {
 | 
			
		||||
        return gsubTable;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual const FontContextualFormsTable* getContextualFormsTable() const
 | 
			
		||||
    {
 | 
			
		||||
        return arabicTable;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    GeneratedFont()
 | 
			
		||||
        : ConstFont(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), glyphData(0), kerningData(0), gsubTable(0), arabicTable(0)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const void* glyphData;          ///< The glyphs
 | 
			
		||||
    const KerningNode* kerningData; ///< The kerning
 | 
			
		||||
    const uint16_t* gsubTable;      ///< The GSUB tables
 | 
			
		||||
 | 
			
		||||
    const FontContextualFormsTable* arabicTable; ///< Contextual forms
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct BinaryFontData
 | 
			
		||||
{
 | 
			
		||||
    uint32_t fontIndex;                // The font index (as used by TypedTextDatabase)
 | 
			
		||||
    uint32_t sizeOfFontData;           // Size of the complete BinaryFont
 | 
			
		||||
    uint32_t offsetToTable;            // GlyphNode[]
 | 
			
		||||
    uint32_t offsetToKerning;          // KerningNode[]
 | 
			
		||||
    uint32_t offsetToGlyphs;           // uint8_t[]
 | 
			
		||||
    uint32_t offsetToGSUB;             // uint16_t[]
 | 
			
		||||
    uint32_t offsetToArabicTable;      // FontContextualFormsTable
 | 
			
		||||
    uint16_t numberOfGlyphs;           // Number of glyphs in Table and Glyphs
 | 
			
		||||
    uint16_t fontHeight;               // Font height
 | 
			
		||||
    uint16_t baseline;                 // Distance to baseline
 | 
			
		||||
    uint8_t pixAboveTop;               // Max pixels above top
 | 
			
		||||
    uint8_t pixBelowBottom;            // Max pixels below bottom
 | 
			
		||||
    uint8_t bitsPerPixel;              // Bpp
 | 
			
		||||
    uint8_t byteAlignRow;              // A4/A2/A1
 | 
			
		||||
    uint8_t maxLeft;                   // The maximum a glyph extends to the left
 | 
			
		||||
    uint8_t maxRight;                  // The maximum a glyph extends to the right
 | 
			
		||||
    Unicode::UnicodeChar fallbackChar; // Fallback Character for the font
 | 
			
		||||
    Unicode::UnicodeChar ellipsisChar; // Ellipsis Character for the font
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class BinaryFont : public GeneratedFont
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    BinaryFont(const struct touchgfx::BinaryFontData* data)
 | 
			
		||||
        : GeneratedFont((const GlyphNode*)((const uint8_t*)data + data->offsetToTable),
 | 
			
		||||
                        data->numberOfGlyphs,
 | 
			
		||||
                        data->fontHeight,
 | 
			
		||||
                        data->baseline,
 | 
			
		||||
                        data->pixAboveTop,
 | 
			
		||||
                        data->pixBelowBottom,
 | 
			
		||||
                        data->bitsPerPixel,
 | 
			
		||||
                        data->byteAlignRow,
 | 
			
		||||
                        data->maxLeft,
 | 
			
		||||
                        data->maxRight,
 | 
			
		||||
                        0,
 | 
			
		||||
                        (const KerningNode*)((const uint8_t*)data + data->offsetToKerning),
 | 
			
		||||
                        data->fallbackChar,
 | 
			
		||||
                        data->ellipsisChar,
 | 
			
		||||
                        (data->offsetToGSUB == 0) ? 0 : (const uint16_t*)((const uint8_t*)data + data->offsetToGSUB),
 | 
			
		||||
                        0),
 | 
			
		||||
          glyphData((const uint8_t*)data + data->offsetToGlyphs)
 | 
			
		||||
    {
 | 
			
		||||
        if (data->offsetToArabicTable > 0)
 | 
			
		||||
        {
 | 
			
		||||
            setupContextualTable(data);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    BinaryFont()
 | 
			
		||||
        : GeneratedFont()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    virtual const uint8_t* getPixelData(const GlyphNode* glyph) const
 | 
			
		||||
    {
 | 
			
		||||
        const uint8_t* data = (const uint8_t*)glyphData;
 | 
			
		||||
        return &(data[glyph->dataOffset]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    const uint8_t* glyphData;
 | 
			
		||||
    FontContextualFormsTable contextualForms;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    typedef const Unicode::UnicodeChar (*array5ptr)[5];
 | 
			
		||||
    typedef const Unicode::UnicodeChar (*array4ptr)[4];
 | 
			
		||||
    void setupContextualTable(const struct touchgfx::BinaryFontData* data)
 | 
			
		||||
    {
 | 
			
		||||
        const uint16_t* const base = (const uint16_t*)(((const uint8_t*)data) + data->offsetToArabicTable);
 | 
			
		||||
        // First elements in binary font are offsets to arrays in 16bit words
 | 
			
		||||
        contextualForms.contextualForms4Long = (array5ptr)(base + base[0]);
 | 
			
		||||
        contextualForms.contextualForms3Long = (array5ptr)(base + base[1]);
 | 
			
		||||
        contextualForms.contextualForms2Long = (array5ptr)(base + base[2]);
 | 
			
		||||
        contextualForms.contextualForms0621_063a = (array4ptr)(base + base[3]);
 | 
			
		||||
        contextualForms.contextualForms0641_064a = (array4ptr)(base + base[4]);
 | 
			
		||||
        contextualForms.contextualForms06XX = (array5ptr)(base + base[5]);
 | 
			
		||||
        contextualForms.contextualForms4LongSize = base[6];
 | 
			
		||||
        contextualForms.contextualForms3LongSize = base[7];
 | 
			
		||||
        contextualForms.contextualForms2LongSize = base[8];
 | 
			
		||||
        contextualForms.contextualForms06XXSize = base[9];
 | 
			
		||||
        arabicTable = &contextualForms;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
} // namespace touchgfx
 | 
			
		||||
 | 
			
		||||
#endif // TOUCHGFX_GENERATEDFONT_HPP
 | 
			
		||||
							
								
								
									
										125
									
								
								TouchGFX/generated/fonts/include/fonts/UnmappedDataFont.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										125
									
								
								TouchGFX/generated/fonts/include/fonts/UnmappedDataFont.hpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,125 @@
 | 
			
		||||
/* DO NOT EDIT THIS FILE */
 | 
			
		||||
/* This file is autogenerated by the text-database code generator */
 | 
			
		||||
 | 
			
		||||
#ifndef TOUCHGFX_UNMAPPEDDATAFONT_HPP
 | 
			
		||||
#define TOUCHGFX_UNMAPPEDDATAFONT_HPP
 | 
			
		||||
 | 
			
		||||
#include <touchgfx/Font.hpp>
 | 
			
		||||
 | 
			
		||||
namespace touchgfx
 | 
			
		||||
{
 | 
			
		||||
/**
 | 
			
		||||
 * An UnmappedDataFont has both glyph table and glyph data placed in a
 | 
			
		||||
 * flash which does not support random access read (indirect
 | 
			
		||||
 * access). A unicode table is located in a flash with random read
 | 
			
		||||
 * access (direct access).
 | 
			
		||||
 *
 | 
			
		||||
 * @see Font, ConstFont
 | 
			
		||||
 */
 | 
			
		||||
class UnmappedDataFont : public Font
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    /**
 | 
			
		||||
     * Construct the UnmappedDataFont.
 | 
			
		||||
     *
 | 
			
		||||
     * @param glyphs                 The array of glyphs known to this font (indirect).
 | 
			
		||||
     * @param unicodes               The array of unicodes known to this font (direct).
 | 
			
		||||
     * @param numGlyphs              The number of glyphs in list.
 | 
			
		||||
     * @param height                 The height in pixels of the highest character in this font.
 | 
			
		||||
     * @param baseline               The height of the baseline in pixels.
 | 
			
		||||
     * @param pixBelowBottom         The maximum number of pixels that can be drawn below the
 | 
			
		||||
     *                               bottom in this font.
 | 
			
		||||
     * @param bitsPerPixel           The number of bits per pixel in this font.
 | 
			
		||||
     * @param byteAlignRow           Are glyphs encoded using A4 format
 | 
			
		||||
     * @param maxLeft                The maximum a character extends to the left.
 | 
			
		||||
     * @param maxRight               The maximum a character extends to the right.
 | 
			
		||||
     * @param glyphDataList          Pointer to pointers the glyph data for the font (indirect).
 | 
			
		||||
     * @param kerningList            pointer to the kerning data for the font (direct).
 | 
			
		||||
     * @param fallbackChar           The fallback character for the typography in case no glyph is
 | 
			
		||||
     *                               available.
 | 
			
		||||
     * @param ellipsisChar           The ellipsis character used for truncating long texts.
 | 
			
		||||
     * @param gsubTable              Pointer to GSUB table (direct).
 | 
			
		||||
     */
 | 
			
		||||
    UnmappedDataFont(const GlyphNode* glyphs, const uint16_t* unicodes, uint16_t numGlyphs, uint16_t height, uint16_t baseline, uint8_t pixAboveTop, uint8_t pixBelowBottom, uint8_t bitsPerPixel, uint8_t byteAlignRow, uint8_t maxLeft, uint8_t maxRight, const uint8_t* const* glyphDataList, const KerningNode* kerningList, const Unicode::UnicodeChar fallbackChar, const Unicode::UnicodeChar ellipsisChar, const uint16_t* const gsubData, const FontContextualFormsTable* formsTable);
 | 
			
		||||
 | 
			
		||||
    using Font::getGlyph;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the glyph data associated with the specified Unicode. The
 | 
			
		||||
       GlyphNode is allocated in the buffer passed to the constructor.
 | 
			
		||||
     *
 | 
			
		||||
     * Please note that in case of Thai letters and Arabic letters
 | 
			
		||||
     * where diacritics can be placed relative to the previous
 | 
			
		||||
     * character(s), please use TextProvider::getNextLigature()
 | 
			
		||||
     * instead as it will create a temporary GlyphNode that will be
 | 
			
		||||
     * adjusted with respect to X/Y position.
 | 
			
		||||
     *
 | 
			
		||||
     * @param       unicode      The character to look up.
 | 
			
		||||
     * @param       pixelData    Pointer to the pixel data for the glyph if the glyph is
 | 
			
		||||
     *                           found. This is set by this method.
 | 
			
		||||
     * @param [out] bitsPerPixel Reference where to place the number of bits per pixel.
 | 
			
		||||
     *
 | 
			
		||||
     * @return A pointer to the glyph node or null if the glyph was not found.
 | 
			
		||||
     */
 | 
			
		||||
    virtual const GlyphNode* getGlyph(Unicode::UnicodeChar unicode, const uint8_t*& pixelData, uint8_t& bitsPerPixel) const;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Obtains the address to the pixel data for the specified glyph.
 | 
			
		||||
     *
 | 
			
		||||
     * @param glyph The glyph to get the pixels data of.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The address of the pixel data of the glyph.
 | 
			
		||||
     */
 | 
			
		||||
    virtual const uint8_t* getPixelData(const GlyphNode* glyph) const;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the kerning distance between two characters.
 | 
			
		||||
     *
 | 
			
		||||
     * @param prevChar The unicode value of the previous character.
 | 
			
		||||
     * @param glyph    the glyph object for the current character.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The kerning distance between prevChar and glyph char.
 | 
			
		||||
     */
 | 
			
		||||
    virtual int8_t getKerning(Unicode::UnicodeChar prevChar, const GlyphNode* glyph) const;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets GSUB table.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The GSUB table or null if font has GSUB no table
 | 
			
		||||
     */
 | 
			
		||||
    virtual const uint16_t* getGSUBTable() const
 | 
			
		||||
    {
 | 
			
		||||
        return gsubTable;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Gets the contextual forms table used in arabic fonts.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The FontContextualFormsTable or null if the font has no table.
 | 
			
		||||
     */
 | 
			
		||||
    virtual const FontContextualFormsTable* getContextualFormsTable() const
 | 
			
		||||
    {
 | 
			
		||||
        return arabicTable;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    UnmappedDataFont()
 | 
			
		||||
        : Font(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), glyphList(0), unicodes(0), glyphDataList(0), kerningData(0), gsubTable(0)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
    int lookupUnicode(uint16_t unicode) const;
 | 
			
		||||
 | 
			
		||||
    const GlyphNode* glyphList;     ///< The list of glyphs
 | 
			
		||||
    uint16_t listSize;              ///< The size of the list of glyphs
 | 
			
		||||
    const uint16_t* unicodes;       ///< LookupTable with all unicodes in this font
 | 
			
		||||
    const void* glyphDataList;      ///< The glyphs (list of pointers)
 | 
			
		||||
    const KerningNode* kerningData; ///< The kerning
 | 
			
		||||
    const uint16_t* gsubTable;      ///< The GSUB tables
 | 
			
		||||
 | 
			
		||||
    const FontContextualFormsTable* arabicTable; ///< Contextual forms
 | 
			
		||||
 | 
			
		||||
    static GlyphNode glyphNodeBuffer; ///< Buffer for GlyphNodes read from unmapped flash
 | 
			
		||||
};
 | 
			
		||||
} // namespace touchgfx
 | 
			
		||||
 | 
			
		||||
#endif // TOUCHGFX_UNMAPPEDDATAFONT_HPP
 | 
			
		||||
							
								
								
									
										24
									
								
								TouchGFX/generated/fonts/src/ApplicationFontProvider.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								TouchGFX/generated/fonts/src/ApplicationFontProvider.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,24 @@
 | 
			
		||||
/* DO NOT EDIT THIS FILE */
 | 
			
		||||
/* This file is autogenerated by the text-database code generator */
 | 
			
		||||
 | 
			
		||||
#include <fonts/ApplicationFontProvider.hpp>
 | 
			
		||||
#include <fonts/GeneratedFont.hpp>
 | 
			
		||||
#include <texts/TypedTextDatabase.hpp>
 | 
			
		||||
 | 
			
		||||
touchgfx::Font* ApplicationFontProvider::getFont(touchgfx::FontId typography)
 | 
			
		||||
{
 | 
			
		||||
    switch (typography)
 | 
			
		||||
    {
 | 
			
		||||
    case Typography::DEFAULT:
 | 
			
		||||
        // verdana_20_4bpp
 | 
			
		||||
        return const_cast<touchgfx::Font*>(TypedTextDatabase::getFonts()[0]);
 | 
			
		||||
    case Typography::LARGE:
 | 
			
		||||
        // verdana_40_4bpp
 | 
			
		||||
        return const_cast<touchgfx::Font*>(TypedTextDatabase::getFonts()[1]);
 | 
			
		||||
    case Typography::SMALL:
 | 
			
		||||
        // verdana_10_4bpp
 | 
			
		||||
        return const_cast<touchgfx::Font*>(TypedTextDatabase::getFonts()[2]);
 | 
			
		||||
    default:
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										55
									
								
								TouchGFX/generated/fonts/src/CachedFont.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								TouchGFX/generated/fonts/src/CachedFont.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,55 @@
 | 
			
		||||
/* DO NOT EDIT THIS FILE */
 | 
			
		||||
/* This file is autogenerated by the text-database code generator */
 | 
			
		||||
 | 
			
		||||
#include <fonts/CachedFont.hpp>
 | 
			
		||||
 | 
			
		||||
namespace touchgfx
 | 
			
		||||
{
 | 
			
		||||
const uint8_t* CachedFont::getPixelData(const GlyphNode* glyph) const
 | 
			
		||||
{
 | 
			
		||||
    // If glyph is cached, then data is present just after the GlyphNode
 | 
			
		||||
    if (FontCache::isCached(glyph))
 | 
			
		||||
    {
 | 
			
		||||
        const uint8_t* data = FontCache::getPixelData(glyph);
 | 
			
		||||
        return data;
 | 
			
		||||
    }
 | 
			
		||||
    return flashFont->getPixelData(glyph);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const GlyphNode* CachedFont::getGlyph(Unicode::UnicodeChar unicode, const uint8_t*& pixelData, uint8_t& bitsPerPixel) const
 | 
			
		||||
{
 | 
			
		||||
    // Look first in internal flash font
 | 
			
		||||
    const GlyphNode* n = flashFont->find(unicode);
 | 
			
		||||
 | 
			
		||||
    if ((n == 0) && (cache != 0))
 | 
			
		||||
    {
 | 
			
		||||
        // Now look in FontCache table
 | 
			
		||||
        n = cache->getGlyph(unicode, fontId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Revert to normal behaviour if still not found
 | 
			
		||||
    if (n == 0 && unicode != 0 && unicode != '\n')
 | 
			
		||||
    {
 | 
			
		||||
        Unicode::UnicodeChar fallbackChar = flashFont->getFallbackChar();
 | 
			
		||||
        n = flashFont->find(fallbackChar);
 | 
			
		||||
        if (n == 0)
 | 
			
		||||
        {
 | 
			
		||||
            n = cache->getGlyph(fallbackChar, fontId);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (n != 0)
 | 
			
		||||
    {
 | 
			
		||||
        pixelData = getPixelData(n);
 | 
			
		||||
        bitsPerPixel = getBitsPerPixel();
 | 
			
		||||
        return n;
 | 
			
		||||
    }
 | 
			
		||||
    return (const GlyphNode*)0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int8_t CachedFont::getKerning(Unicode::UnicodeChar prevChar, const GlyphNode* glyph) const
 | 
			
		||||
{
 | 
			
		||||
    // Kerning is not supported by Font Caching
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
} // namespace touchgfx
 | 
			
		||||
							
								
								
									
										425
									
								
								TouchGFX/generated/fonts/src/FontCache.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										425
									
								
								TouchGFX/generated/fonts/src/FontCache.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,425 @@
 | 
			
		||||
/* DO NOT EDIT THIS FILE */
 | 
			
		||||
/* This file is autogenerated by the text-database code generator */
 | 
			
		||||
 | 
			
		||||
#include <cstring>
 | 
			
		||||
#include <touchgfx/TextProvider.hpp>
 | 
			
		||||
#include <touchgfx/Utils.hpp>
 | 
			
		||||
#include <fonts/CachedFont.hpp>
 | 
			
		||||
#include <fonts/FontCache.hpp>
 | 
			
		||||
#include <texts/TypedTextDatabase.hpp>
 | 
			
		||||
 | 
			
		||||
namespace touchgfx
 | 
			
		||||
{
 | 
			
		||||
FontCache::FontCache()
 | 
			
		||||
    : memorySize(0), memory(0), top(0), gsubStart(0), reader(0)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FontCache::clear(bool keepGsubOrContextTable /* = false */)
 | 
			
		||||
{
 | 
			
		||||
    memset(fontTable, 0, sizeof(fontTable));
 | 
			
		||||
 | 
			
		||||
    // Top is beginning of memory, no glyphs are cached yet
 | 
			
		||||
    top = memory;
 | 
			
		||||
 | 
			
		||||
    if (!keepGsubOrContextTable)
 | 
			
		||||
    {
 | 
			
		||||
        // gsubStart points to end of memory (nothing loaded yet)
 | 
			
		||||
        gsubStart = memory + memorySize;
 | 
			
		||||
 | 
			
		||||
        // Round down to 32bit address
 | 
			
		||||
        gsubStart = (uint8_t*)((uintptr_t)gsubStart & ~(uintptr_t)0x3);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FontCache::setMemory(uint8_t* _memory, uint32_t size)
 | 
			
		||||
{
 | 
			
		||||
    memory = _memory;
 | 
			
		||||
    memorySize = size;
 | 
			
		||||
 | 
			
		||||
    clear();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FontCache::setReader(FontDataReader* _reader)
 | 
			
		||||
{
 | 
			
		||||
    reader = _reader;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const GlyphNode* FontCache::getGlyph(Unicode::UnicodeChar unicode, FontId font) const
 | 
			
		||||
{
 | 
			
		||||
    GlyphNode* g = (GlyphNode*)fontTable[font].first;
 | 
			
		||||
    while (g)
 | 
			
		||||
    {
 | 
			
		||||
        if (g->unicode == unicode)
 | 
			
		||||
        {
 | 
			
		||||
            return g;
 | 
			
		||||
        }
 | 
			
		||||
        GlyphNode** next = (GlyphNode**)((uint8_t*)g + SizeGlyphNode);
 | 
			
		||||
        g = *next;
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FontCache::open()
 | 
			
		||||
{
 | 
			
		||||
    if (reader)
 | 
			
		||||
    {
 | 
			
		||||
        reader->open();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FontCache::close()
 | 
			
		||||
{
 | 
			
		||||
    if (reader)
 | 
			
		||||
    {
 | 
			
		||||
        reader->close();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FontCache::initializeCachedFont(TypedText t, CachedFont* font, bool loadGsubOrContextTable /*= false*/)
 | 
			
		||||
{
 | 
			
		||||
    // Get font index from typed text
 | 
			
		||||
    FontId fontId = t.getFontId();
 | 
			
		||||
    // Reset to start of file
 | 
			
		||||
    open();
 | 
			
		||||
    setPosition(0);
 | 
			
		||||
 | 
			
		||||
    assert(sizeof(touchgfx::BinaryFontData) < MAX_BUFFER_SIZE);
 | 
			
		||||
    readData(buffer, sizeof(touchgfx::BinaryFontData));
 | 
			
		||||
    const struct touchgfx::BinaryFontData* binaryFontData = reinterpret_cast<const struct touchgfx::BinaryFontData*>(buffer);
 | 
			
		||||
 | 
			
		||||
    const Font** flashFonts = TypedTextDatabase::getFonts();
 | 
			
		||||
    const GeneratedFont* flashFont = static_cast<const GeneratedFont*>(flashFonts[fontId]);
 | 
			
		||||
    *font = CachedFont(reinterpret_cast<const struct touchgfx::BinaryFontData*>(buffer), fontId, this, flashFont);
 | 
			
		||||
 | 
			
		||||
    if (loadGsubOrContextTable && (binaryFontData->offsetToGSUB != 0))
 | 
			
		||||
    {
 | 
			
		||||
        setPosition(binaryFontData->offsetToGSUB);
 | 
			
		||||
 | 
			
		||||
        const uint32_t sizeOfGSUB = (binaryFontData->offsetToArabicTable != 0 ? binaryFontData->offsetToArabicTable : binaryFontData->sizeOfFontData) - binaryFontData->offsetToGSUB;
 | 
			
		||||
 | 
			
		||||
        if (top + sizeOfGSUB < gsubStart) // Room for this GSUB table
 | 
			
		||||
        {
 | 
			
		||||
            uint8_t* const gsubPosition = gsubStart - sizeOfGSUB;
 | 
			
		||||
            readData(gsubPosition, sizeOfGSUB);
 | 
			
		||||
            font->setGSUBTable(reinterpret_cast<uint16_t*>(gsubPosition));
 | 
			
		||||
            gsubStart -= sizeOfGSUB;
 | 
			
		||||
 | 
			
		||||
            // Round down to 32bit address
 | 
			
		||||
            gsubStart = (uint8_t*)((uintptr_t)gsubStart & ~(uintptr_t)0x3);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            font->setGSUBTable(0);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (loadGsubOrContextTable && (binaryFontData->offsetToArabicTable != 0))
 | 
			
		||||
    {
 | 
			
		||||
        setPosition(binaryFontData->offsetToArabicTable);
 | 
			
		||||
 | 
			
		||||
        const uint32_t sizeTableData = binaryFontData->sizeOfFontData - binaryFontData->offsetToArabicTable;
 | 
			
		||||
 | 
			
		||||
        if (top + sizeTableData + sizeof(FontContextualFormsTable) < gsubStart) // Room for the ContextualFormsTables
 | 
			
		||||
        {
 | 
			
		||||
            // Allocate FontContextualFormsTable first
 | 
			
		||||
            gsubStart -= sizeof(FontContextualFormsTable);
 | 
			
		||||
            // Round down to 32bit address
 | 
			
		||||
            gsubStart = (uint8_t*)((uintptr_t)gsubStart & ~(uintptr_t)0x3);
 | 
			
		||||
 | 
			
		||||
            FontContextualFormsTable* table = (FontContextualFormsTable*)gsubStart;
 | 
			
		||||
            font->setContextualFormsTable(table);
 | 
			
		||||
            gsubStart -= sizeTableData;
 | 
			
		||||
            readData(gsubStart, sizeTableData);
 | 
			
		||||
 | 
			
		||||
            // Set pointers in table
 | 
			
		||||
            const uint16_t* const base = (const uint16_t*)gsubStart;
 | 
			
		||||
            // First elements in binary font are offsets to arrays in 16bit words
 | 
			
		||||
            table->contextualForms4Long = (FontContextualFormsTable::arrayOf5UnicodesPtr)(base + base[0]);
 | 
			
		||||
            table->contextualForms3Long = (FontContextualFormsTable::arrayOf5UnicodesPtr)(base + base[1]);
 | 
			
		||||
            table->contextualForms2Long = (FontContextualFormsTable::arrayOf5UnicodesPtr)(base + base[2]);
 | 
			
		||||
            table->contextualForms0621_063a = (FontContextualFormsTable::arrayOf4UnicodesPtr)(base + base[3]);
 | 
			
		||||
            table->contextualForms0641_064a = (FontContextualFormsTable::arrayOf4UnicodesPtr)(base + base[4]);
 | 
			
		||||
            table->contextualForms06XX = (FontContextualFormsTable::arrayOf5UnicodesPtr)(base + base[5]);
 | 
			
		||||
            table->contextualForms4LongSize = base[6];
 | 
			
		||||
            table->contextualForms3LongSize = base[7];
 | 
			
		||||
            table->contextualForms2LongSize = base[8];
 | 
			
		||||
            table->contextualForms06XXSize = base[9];
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            font->setContextualFormsTable(0);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    close();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool FontCache::cacheString(TypedText t, const Unicode::UnicodeChar* string)
 | 
			
		||||
{
 | 
			
		||||
    open();
 | 
			
		||||
    if (!createSortedString(string))
 | 
			
		||||
    {
 | 
			
		||||
        close();
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    const bool result = cacheSortedString(t);
 | 
			
		||||
    close();
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool FontCache::cacheLigatures(CachedFont* font, TypedText t, const Unicode::UnicodeChar* string)
 | 
			
		||||
{
 | 
			
		||||
    open();
 | 
			
		||||
    if (!createSortedLigatures(font, t, string, 0, 0))
 | 
			
		||||
    {
 | 
			
		||||
        close();
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    const bool result = cacheSortedString(t);
 | 
			
		||||
    close();
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool FontCache::cacheSortedString(TypedText t)
 | 
			
		||||
{
 | 
			
		||||
    setPosition(8); // Skip font index and size
 | 
			
		||||
    uint32_t glyphNodeOffset;
 | 
			
		||||
    uint32_t dummy;
 | 
			
		||||
    readData(&glyphNodeOffset, sizeof(uint32_t)); // offsetToTable
 | 
			
		||||
    readData(&dummy, sizeof(uint32_t));           // offsetToKerning
 | 
			
		||||
    readData(&glyphDataOffset, sizeof(uint32_t)); // offsetToGlyphs
 | 
			
		||||
    readData(&dummy, sizeof(uint32_t));           // offsetToGlyphs
 | 
			
		||||
    readData(&dummy, sizeof(uint32_t));           // offsetToArabicTable
 | 
			
		||||
    readData(&numGlyphs, sizeof(uint16_t));       // numberOfGlyphs
 | 
			
		||||
 | 
			
		||||
    FontId fontId = t.getFontId();                 // Get font index from typed text
 | 
			
		||||
    uint32_t bpp = t.getFont()->getBitsPerPixel(); // Get BPP from standard font
 | 
			
		||||
 | 
			
		||||
    setPosition(glyphNodeOffset); // Go to glyph nodes for font
 | 
			
		||||
    currentFileGlyphNumber = 0;
 | 
			
		||||
    currentFileGlyphNode.unicode = 0; // Force reading of first glyph
 | 
			
		||||
 | 
			
		||||
    const Unicode::UnicodeChar* string = sortedString;
 | 
			
		||||
    Unicode::UnicodeChar last = 0;
 | 
			
		||||
    GlyphNode* firstNewGlyph = 0;
 | 
			
		||||
    bool outOfMemory = false;
 | 
			
		||||
    while (*string)
 | 
			
		||||
    {
 | 
			
		||||
        Unicode::UnicodeChar ch = *string;
 | 
			
		||||
        if (ch != last)
 | 
			
		||||
        {
 | 
			
		||||
            if (!contains(ch, fontId))
 | 
			
		||||
            {
 | 
			
		||||
                insert(ch, fontId, bpp, outOfMemory);
 | 
			
		||||
                if (outOfMemory)
 | 
			
		||||
                {
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
                if (firstNewGlyph == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    firstNewGlyph = (GlyphNode*)fontTable[fontId].last;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        last = ch;
 | 
			
		||||
        string++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    cacheData(bpp, firstNewGlyph);
 | 
			
		||||
    return !outOfMemory;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool FontCache::contains(Unicode::UnicodeChar unicode, FontId font) const
 | 
			
		||||
{
 | 
			
		||||
    GlyphNode* g = (GlyphNode*)fontTable[font].first;
 | 
			
		||||
    while (g)
 | 
			
		||||
    {
 | 
			
		||||
        if (g->unicode == unicode)
 | 
			
		||||
        {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        GlyphNode** next = (GlyphNode**)((uint8_t*)g + SizeGlyphNode);
 | 
			
		||||
        g = *next;
 | 
			
		||||
    }
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FontCache::insert(Unicode::UnicodeChar unicode, FontId font, uint32_t bpp, bool& outOfMemory)
 | 
			
		||||
{
 | 
			
		||||
    // Insert new glyphnode and glyph after last for font.
 | 
			
		||||
    uint8_t* oldTop = top;
 | 
			
		||||
    top = copyGlyph(top, unicode, font, bpp, outOfMemory);
 | 
			
		||||
 | 
			
		||||
    if (top == oldTop)
 | 
			
		||||
    {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (fontTable[font].last == 0)
 | 
			
		||||
    {
 | 
			
		||||
        // First glyph
 | 
			
		||||
        fontTable[font].first = oldTop;
 | 
			
		||||
        fontTable[font].last = oldTop;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        // Set next pointer of old last glyph
 | 
			
		||||
        uint8_t** old_next = (uint8_t**)(fontTable[font].last + SizeGlyphNode);
 | 
			
		||||
        *old_next = oldTop;
 | 
			
		||||
 | 
			
		||||
        // Save new glyph as last glyph
 | 
			
		||||
        fontTable[font].last = oldTop;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t* FontCache::copyGlyph(uint8_t* top, Unicode::UnicodeChar unicode, FontId font, uint32_t bpp, bool& outOfMemory)
 | 
			
		||||
{
 | 
			
		||||
    while (currentFileGlyphNumber < numGlyphs && currentFileGlyphNode.unicode < unicode)
 | 
			
		||||
    {
 | 
			
		||||
        readData(¤tFileGlyphNode, sizeof(GlyphNode));
 | 
			
		||||
        currentFileGlyphNumber++;
 | 
			
		||||
    }
 | 
			
		||||
    if (currentFileGlyphNode.unicode != unicode)
 | 
			
		||||
    {
 | 
			
		||||
        // GlyphNode not found
 | 
			
		||||
        return top;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // GlyphNode found
 | 
			
		||||
    uint32_t glyphSize = ((currentFileGlyphNode.width() + 1) & ~1) * currentFileGlyphNode.height() * bpp / 8;
 | 
			
		||||
    glyphSize = (glyphSize + 3) & ~0x03;
 | 
			
		||||
    uint32_t requiredMem = SizeGlyphNode + 4 + glyphSize; // GlyphNode + next ptr + glyph
 | 
			
		||||
 | 
			
		||||
    // Is space available before sortedString
 | 
			
		||||
    if (top + requiredMem > (uint8_t*)sortedString)
 | 
			
		||||
    {
 | 
			
		||||
        outOfMemory = true;
 | 
			
		||||
        return top;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    *(GlyphNode*)top = currentFileGlyphNode;
 | 
			
		||||
 | 
			
		||||
    // Clear next pointer
 | 
			
		||||
    uint8_t** next = (uint8_t**)(top + SizeGlyphNode);
 | 
			
		||||
    *next = 0;
 | 
			
		||||
    top += requiredMem;
 | 
			
		||||
    return top;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FontCache::cacheData(uint32_t bpp, GlyphNode* first)
 | 
			
		||||
{
 | 
			
		||||
    GlyphNode* gn = first;
 | 
			
		||||
    while (gn)
 | 
			
		||||
    {
 | 
			
		||||
        uint8_t* p = (uint8_t*)gn;
 | 
			
		||||
        if (gn->dataOffset != 0xFFFFFFFF)
 | 
			
		||||
        {
 | 
			
		||||
            p += SizeGlyphNode;
 | 
			
		||||
            // Next pointer
 | 
			
		||||
            p += 4;
 | 
			
		||||
 | 
			
		||||
            // Seek and copy
 | 
			
		||||
            setPosition(glyphDataOffset + gn->dataOffset);
 | 
			
		||||
            uint32_t glyphSize = ((gn->width() + 1) & ~1) * gn->height() * bpp / 8;
 | 
			
		||||
            readData(p, glyphSize);
 | 
			
		||||
 | 
			
		||||
            // Mark glyphNode as cached
 | 
			
		||||
            gn->dataOffset = 0xFFFFFFFF;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        GlyphNode** next = (GlyphNode**)((uint8_t*)gn + SizeGlyphNode);
 | 
			
		||||
        gn = *next;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool FontCache::createSortedString(const Unicode::UnicodeChar* string)
 | 
			
		||||
{
 | 
			
		||||
    int length = Unicode::strlen(string);
 | 
			
		||||
    // Sorted string is allocated at end of buffer
 | 
			
		||||
    sortedString = (Unicode::UnicodeChar*)(gsubStart - (length + 1) * 2);
 | 
			
		||||
    if ((uint8_t*)sortedString < top)
 | 
			
		||||
    {
 | 
			
		||||
        // Unable to allocate string buffer in end of memory
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    int n = 0;
 | 
			
		||||
    Unicode::UnicodeChar* uc = sortedString;
 | 
			
		||||
    while (*string)
 | 
			
		||||
    {
 | 
			
		||||
        *uc++ = *string++;
 | 
			
		||||
        n++;
 | 
			
		||||
    }
 | 
			
		||||
    *uc = 0;
 | 
			
		||||
    return sortSortedString(n);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool FontCache::createSortedLigatures(CachedFont* font, TypedText t, const Unicode::UnicodeChar* string, ...)
 | 
			
		||||
{
 | 
			
		||||
    va_list pArg;
 | 
			
		||||
    va_start(pArg, string);
 | 
			
		||||
    TextProvider tp;
 | 
			
		||||
    tp.initialize(string, pArg, font->getGSUBTable(), font->getContextualFormsTable());
 | 
			
		||||
    va_end(pArg);
 | 
			
		||||
    Unicode::UnicodeChar ligature;
 | 
			
		||||
    sortedString = (Unicode::UnicodeChar*)(gsubStart);
 | 
			
		||||
    if ((uint8_t*)(sortedString - 1) < top)
 | 
			
		||||
    {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    *--sortedString = 0;
 | 
			
		||||
    int n = 0;
 | 
			
		||||
    while ((ligature = tp.getNextLigature(t.getTextDirection())) != 0)
 | 
			
		||||
    {
 | 
			
		||||
        if ((uint8_t*)(sortedString - 1) < top)
 | 
			
		||||
        {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        *--sortedString = ligature;
 | 
			
		||||
        n++;
 | 
			
		||||
    }
 | 
			
		||||
    return sortSortedString(n);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool FontCache::sortSortedString(int n)
 | 
			
		||||
{
 | 
			
		||||
    Unicode::UnicodeChar* uc = sortedString;
 | 
			
		||||
    for (int i = 0; i < n - 1; i++)
 | 
			
		||||
    {
 | 
			
		||||
        bool swapped = false;
 | 
			
		||||
        for (int j = 0; j < n - i - 1; j++)
 | 
			
		||||
        {
 | 
			
		||||
            if (uc[j] > uc[j + 1])
 | 
			
		||||
            {
 | 
			
		||||
                Unicode::UnicodeChar temp = uc[j];
 | 
			
		||||
                uc[j] = uc[j + 1];
 | 
			
		||||
                uc[j + 1] = temp;
 | 
			
		||||
                swapped = true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // If no two elements were swapped by inner loop, then break
 | 
			
		||||
        if (!swapped)
 | 
			
		||||
        {
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FontCache::setPosition(uint32_t position)
 | 
			
		||||
{
 | 
			
		||||
    if (reader)
 | 
			
		||||
    {
 | 
			
		||||
        reader->setPosition(position);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FontCache::readData(void* out, uint32_t numberOfBytes)
 | 
			
		||||
{
 | 
			
		||||
    if (reader)
 | 
			
		||||
    {
 | 
			
		||||
        reader->readData(out, numberOfBytes);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
} // namespace touchgfx
 | 
			
		||||
							
								
								
									
										8
									
								
								TouchGFX/generated/fonts/src/Font_verdana_10_4bpp_0.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								TouchGFX/generated/fonts/src/Font_verdana_10_4bpp_0.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
			
		||||
#include <touchgfx/hal/Types.hpp>
 | 
			
		||||
 | 
			
		||||
FONT_GLYPH_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const uint8_t unicodes_verdana_10_4bpp_0[] FONT_GLYPH_LOCATION_FLASH_ATTRIBUTE = {
 | 
			
		||||
    // Unicode: [0x003F]
 | 
			
		||||
    0xD2, 0xCE, 0x03, 0x21, 0x50, 0x0C, 0x00, 0x30, 0x0C, 0x00, 0xC1, 0x05, 0x00, 0x4D, 0x00, 0x00,
 | 
			
		||||
    0x0C, 0x00, 0x00, 0x02, 0x00, 0x00, 0x0F, 0x00
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										57
									
								
								TouchGFX/generated/fonts/src/Font_verdana_20_4bpp_0.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								TouchGFX/generated/fonts/src/Font_verdana_20_4bpp_0.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,57 @@
 | 
			
		||||
#include <touchgfx/hal/Types.hpp>
 | 
			
		||||
 | 
			
		||||
FONT_GLYPH_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const uint8_t unicodes_verdana_20_4bpp_0[] FONT_GLYPH_LOCATION_FLASH_ATTRIBUTE = {
 | 
			
		||||
    // Unicode: [0x003F]
 | 
			
		||||
    0x93, 0xEC, 0xDE, 0x29, 0x00, 0xF7, 0xAD, 0xDA, 0xEF, 0x02, 0x33, 0x00, 0x00, 0xF9, 0x0A, 0x00,
 | 
			
		||||
    0x00, 0x00, 0xF3, 0x0C, 0x00, 0x00, 0x00, 0xF5, 0x0A, 0x00, 0x00, 0x10, 0xFD, 0x03, 0x00, 0x00,
 | 
			
		||||
    0xD5, 0x6F, 0x00, 0x00, 0xB0, 0xCF, 0x03, 0x00, 0x00, 0xE0, 0x0C, 0x00, 0x00, 0x00, 0xE0, 0x0C,
 | 
			
		||||
    0x00, 0x00, 0x00, 0x40, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x0E, 0x00,
 | 
			
		||||
    0x00, 0x00, 0xF0, 0x0E, 0x00, 0x00,
 | 
			
		||||
    // Unicode: [0x0042]
 | 
			
		||||
    0xF1, 0xFF, 0xFF, 0xDF, 0x3A, 0x00, 0xF1, 0x9E, 0x99, 0xDA, 0xFF, 0x03, 0xF1, 0x0D, 0x00, 0x00,
 | 
			
		||||
    0xF9, 0x09, 0xF1, 0x0D, 0x00, 0x00, 0xF6, 0x09, 0xF1, 0x0D, 0x00, 0x00, 0xFB, 0x03, 0xF1, 0x9E,
 | 
			
		||||
    0x99, 0xEA, 0x4E, 0x00, 0xF1, 0xFF, 0xFF, 0xFF, 0xEF, 0x05, 0xF1, 0x0D, 0x00, 0x10, 0xE5, 0x4F,
 | 
			
		||||
    0xF1, 0x0D, 0x00, 0x00, 0x40, 0xBF, 0xF1, 0x0D, 0x00, 0x00, 0x20, 0xDF, 0xF1, 0x0D, 0x00, 0x00,
 | 
			
		||||
    0x30, 0xCF, 0xF1, 0x0D, 0x00, 0x00, 0xC1, 0x7F, 0xF1, 0x9E, 0x99, 0xBA, 0xFF, 0x0A, 0xF1, 0xFF,
 | 
			
		||||
    0xFF, 0xEF, 0x5B, 0x00,
 | 
			
		||||
    // Unicode: [0x0046]
 | 
			
		||||
    0xF1, 0xFF, 0xFF, 0xFF, 0xFF, 0x04, 0xF1, 0xAE, 0xAA, 0xAA, 0xAA, 0x02, 0xF1, 0x0D, 0x00, 0x00,
 | 
			
		||||
    0x00, 0x00, 0xF1, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xF1, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xF1, 0xAF,
 | 
			
		||||
    0xAA, 0xAA, 0x2A, 0x00, 0xF1, 0xFF, 0xFF, 0xFF, 0x3F, 0x00, 0xF1, 0x0D, 0x00, 0x00, 0x00, 0x00,
 | 
			
		||||
    0xF1, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xF1, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xF1, 0x0D, 0x00, 0x00,
 | 
			
		||||
    0x00, 0x00, 0xF1, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xF1, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xF1, 0x0D,
 | 
			
		||||
    0x00, 0x00, 0x00, 0x00,
 | 
			
		||||
    // Unicode: [0x0053]
 | 
			
		||||
    0x00, 0xA4, 0xFD, 0xDF, 0x7B, 0x02, 0x80, 0xFF, 0xAC, 0xCA, 0xFF, 0x0E, 0xF4, 0x3E, 0x00, 0x00,
 | 
			
		||||
    0x61, 0x0C, 0xF9, 0x07, 0x00, 0x00, 0x00, 0x00, 0xF7, 0x09, 0x00, 0x00, 0x00, 0x00, 0xF3, 0x8F,
 | 
			
		||||
    0x03, 0x00, 0x00, 0x00, 0x50, 0xFE, 0xFF, 0xAD, 0x17, 0x00, 0x00, 0x50, 0xB8, 0xFE, 0xFF, 0x06,
 | 
			
		||||
    0x00, 0x00, 0x00, 0x20, 0xF7, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x90, 0x7F, 0x03, 0x00, 0x00, 0x00,
 | 
			
		||||
    0x90, 0x6F, 0xBA, 0x04, 0x00, 0x00, 0xE5, 0x2E, 0xFA, 0xEF, 0xAB, 0xDB, 0xEF, 0x05, 0x50, 0xC9,
 | 
			
		||||
    0xFE, 0xCE, 0x28, 0x00,
 | 
			
		||||
    // Unicode: [0x0054]
 | 
			
		||||
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x05, 0xAA, 0xAA, 0xEA, 0xBF, 0xAA, 0xAA, 0x03, 0x00, 0x00,
 | 
			
		||||
    0xC0, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x2F,
 | 
			
		||||
    0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x2F, 0x00, 0x00,
 | 
			
		||||
    0x00, 0x00, 0x00, 0xC0, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x2F, 0x00, 0x00, 0x00, 0x00,
 | 
			
		||||
    0x00, 0xC0, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0,
 | 
			
		||||
    0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x2F, 0x00,
 | 
			
		||||
    0x00, 0x00,
 | 
			
		||||
    // Unicode: [0x0055]
 | 
			
		||||
    0xF4, 0x0A, 0x00, 0x00, 0x00, 0xEF, 0xF4, 0x0A, 0x00, 0x00, 0x00, 0xEF, 0xF4, 0x0A, 0x00, 0x00,
 | 
			
		||||
    0x00, 0xEF, 0xF4, 0x0A, 0x00, 0x00, 0x00, 0xEF, 0xF4, 0x0A, 0x00, 0x00, 0x00, 0xEF, 0xF4, 0x0A,
 | 
			
		||||
    0x00, 0x00, 0x00, 0xEF, 0xF4, 0x0A, 0x00, 0x00, 0x00, 0xEF, 0xF4, 0x0A, 0x00, 0x00, 0x00, 0xEF,
 | 
			
		||||
    0xF4, 0x0A, 0x00, 0x00, 0x10, 0xDF, 0xF3, 0x0B, 0x00, 0x00, 0x20, 0xCF, 0xF0, 0x1F, 0x00, 0x00,
 | 
			
		||||
    0x70, 0x9F, 0x90, 0xAF, 0x01, 0x00, 0xE3, 0x4F, 0x10, 0xFC, 0xBE, 0xCA, 0xFF, 0x08, 0x00, 0x71,
 | 
			
		||||
    0xEC, 0xEF, 0x4B, 0x00,
 | 
			
		||||
    // Unicode: [0x0061]
 | 
			
		||||
    0x90, 0xEC, 0xEF, 0x7C, 0x00, 0xF0, 0xBD, 0xA9, 0xFE, 0x0A, 0x30, 0x00, 0x00, 0xD1, 0x2F, 0x00,
 | 
			
		||||
    0x00, 0x00, 0xA1, 0x4F, 0x20, 0xC8, 0xFE, 0xFF, 0x4F, 0xE3, 0xBF, 0x68, 0xA5, 0x4F, 0xFC, 0x05,
 | 
			
		||||
    0x00, 0x80, 0x4F, 0xEE, 0x00, 0x00, 0x80, 0x4F, 0xFD, 0x03, 0x00, 0xD5, 0x4F, 0xF6, 0xBF, 0xDB,
 | 
			
		||||
    0xEF, 0x4F, 0x50, 0xFC, 0xAE, 0x83, 0x4F,
 | 
			
		||||
    // Unicode: [0x0065]
 | 
			
		||||
    0x00, 0xB4, 0xFE, 0x9D, 0x02, 0x70, 0xDF, 0x89, 0xFA, 0x2E, 0xF3, 0x09, 0x00, 0x50, 0x9F, 0xFA,
 | 
			
		||||
    0x12, 0x11, 0x11, 0xDE, 0xFD, 0xFF, 0xFF, 0xFF, 0xEF, 0xEE, 0x44, 0x44, 0x44, 0x44, 0xFD, 0x01,
 | 
			
		||||
    0x00, 0x00, 0x00, 0xFA, 0x06, 0x00, 0x00, 0x00, 0xF4, 0x4E, 0x00, 0x00, 0x84, 0x70, 0xFF, 0x9C,
 | 
			
		||||
    0xDA, 0xBF, 0x00, 0xA4, 0xFD, 0xCE, 0x28
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										24
									
								
								TouchGFX/generated/fonts/src/Font_verdana_40_4bpp_0.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								TouchGFX/generated/fonts/src/Font_verdana_40_4bpp_0.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,24 @@
 | 
			
		||||
#include <touchgfx/hal/Types.hpp>
 | 
			
		||||
 | 
			
		||||
FONT_GLYPH_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const uint8_t unicodes_verdana_40_4bpp_0[] FONT_GLYPH_LOCATION_FLASH_ATTRIBUTE = {
 | 
			
		||||
    // Unicode: [0x003F]
 | 
			
		||||
    0x00, 0x10, 0x53, 0x77, 0x57, 0x02, 0x00, 0x00, 0x00, 0x83, 0xFC, 0xFF, 0xFF, 0xFF, 0xDF, 0x17,
 | 
			
		||||
    0x00, 0x00, 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0x02, 0x00, 0xFD, 0xFF, 0xFF, 0xEF, 0xFF,
 | 
			
		||||
    0xFF, 0xFF, 0x2E, 0x00, 0xFD, 0x9E, 0x15, 0x00, 0x41, 0xFA, 0xFF, 0xBF, 0x00, 0x6B, 0x00, 0x00,
 | 
			
		||||
    0x00, 0x00, 0x60, 0xFF, 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFB, 0xFF, 0x07, 0x00,
 | 
			
		||||
    0x00, 0x00, 0x00, 0x00, 0x00, 0xF7, 0xFF, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF6, 0xFF,
 | 
			
		||||
    0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF7, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 | 
			
		||||
    0xFB, 0xFF, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xFF, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00,
 | 
			
		||||
    0x00, 0xC1, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xFC, 0xFF, 0x0C, 0x00, 0x00, 0x00,
 | 
			
		||||
    0x00, 0x00, 0xD3, 0xFF, 0xDF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x81, 0xFF, 0xFF, 0x2C, 0x00, 0x00,
 | 
			
		||||
    0x00, 0x00, 0x60, 0xFE, 0xFF, 0x9F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0xFF, 0xDF, 0x04, 0x00,
 | 
			
		||||
    0x00, 0x00, 0x00, 0x00, 0xD0, 0xFF, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0xFF, 0x09,
 | 
			
		||||
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0xFF, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0,
 | 
			
		||||
    0xFF, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0xFF, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00,
 | 
			
		||||
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 | 
			
		||||
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x44, 0x03, 0x00,
 | 
			
		||||
    0x00, 0x00, 0x00, 0x00, 0x00, 0xF1, 0xFF, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF1, 0xFF,
 | 
			
		||||
    0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF1, 0xFF, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 | 
			
		||||
    0xF1, 0xFF, 0x0E, 0x00, 0x00, 0x00, 0x00
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										44
									
								
								TouchGFX/generated/fonts/src/GeneratedFont.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								TouchGFX/generated/fonts/src/GeneratedFont.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,44 @@
 | 
			
		||||
/* DO NOT EDIT THIS FILE */
 | 
			
		||||
/* This file is autogenerated by the text-database code generator */
 | 
			
		||||
 | 
			
		||||
#include <fonts/GeneratedFont.hpp>
 | 
			
		||||
 | 
			
		||||
namespace touchgfx
 | 
			
		||||
{
 | 
			
		||||
GeneratedFont::GeneratedFont(const GlyphNode* glyphs, uint16_t numGlyphs, uint16_t height, uint16_t baseline, uint8_t pixAboveTop, uint8_t pixBelowBottom, uint8_t bitsPerPixel, uint8_t byteAlignRow, uint8_t maxLeft, uint8_t maxRight, const uint8_t* const* glyphDataInternalFlash, const KerningNode* kerningList, const Unicode::UnicodeChar fallbackChar, const Unicode::UnicodeChar ellipsisChar, const uint16_t* const gsubData, const FontContextualFormsTable* formsTable)
 | 
			
		||||
    : ConstFont(glyphs, numGlyphs, height, baseline, pixAboveTop, pixBelowBottom, bitsPerPixel, byteAlignRow, maxLeft, maxRight, fallbackChar, ellipsisChar),
 | 
			
		||||
      glyphData(glyphDataInternalFlash),
 | 
			
		||||
      kerningData(kerningList),
 | 
			
		||||
      gsubTable(gsubData),
 | 
			
		||||
      arabicTable(formsTable)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const uint8_t* GeneratedFont::getPixelData(const GlyphNode* glyph) const
 | 
			
		||||
{
 | 
			
		||||
    const uint8_t* const* table = (const uint8_t* const*)glyphData;
 | 
			
		||||
    return &(table[glyph->unicode / 2048][glyph->dataOffset]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int8_t GeneratedFont::getKerning(Unicode::UnicodeChar prevChar, const GlyphNode* glyph) const
 | 
			
		||||
{
 | 
			
		||||
    if (!glyph || glyph->kerningTableSize == 0)
 | 
			
		||||
    {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const KerningNode* kerndata = kerningData + glyph->kerningTablePos();
 | 
			
		||||
    for (uint16_t i = glyph->kerningTableSize; i > 0; i--, kerndata++)
 | 
			
		||||
    {
 | 
			
		||||
        if (prevChar == kerndata->unicodePrevChar)
 | 
			
		||||
        {
 | 
			
		||||
            return kerndata->distance;
 | 
			
		||||
        }
 | 
			
		||||
        if (prevChar < kerndata->unicodePrevChar)
 | 
			
		||||
        {
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
} // namespace touchgfx
 | 
			
		||||
							
								
								
									
										6
									
								
								TouchGFX/generated/fonts/src/Kerning_verdana_10_4bpp.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								TouchGFX/generated/fonts/src/Kerning_verdana_10_4bpp.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
#include <touchgfx/Font.hpp>
 | 
			
		||||
 | 
			
		||||
FONT_KERNING_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const touchgfx::KerningNode kerning_verdana_10_4bpp[] FONT_KERNING_LOCATION_FLASH_ATTRIBUTE = {
 | 
			
		||||
    { 0, 0 }
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										10
									
								
								TouchGFX/generated/fonts/src/Kerning_verdana_20_4bpp.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								TouchGFX/generated/fonts/src/Kerning_verdana_20_4bpp.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
			
		||||
#include <touchgfx/Font.hpp>
 | 
			
		||||
 | 
			
		||||
FONT_KERNING_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const touchgfx::KerningNode kerning_verdana_20_4bpp[] FONT_KERNING_LOCATION_FLASH_ATTRIBUTE = {
 | 
			
		||||
    { 0x0054, -1 },  // (First char = [0x0054, T], Second char = [0x0054, T], Kerning dist = -1)
 | 
			
		||||
    { 0x0065, -1 },  // (First char = [0x0065, e], Second char = [0x0054, T], Kerning dist = -1)
 | 
			
		||||
    { 0x0046, -1 },  // (First char = [0x0046, F], Second char = [0x0061, a], Kerning dist = -1)
 | 
			
		||||
    { 0x0054, -2 },  // (First char = [0x0054, T], Second char = [0x0061, a], Kerning dist = -2)
 | 
			
		||||
    { 0x0054, -2 },  // (First char = [0x0054, T], Second char = [0x0065, e], Kerning dist = -2)
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										6
									
								
								TouchGFX/generated/fonts/src/Kerning_verdana_40_4bpp.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								TouchGFX/generated/fonts/src/Kerning_verdana_40_4bpp.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
#include <touchgfx/Font.hpp>
 | 
			
		||||
 | 
			
		||||
FONT_KERNING_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const touchgfx::KerningNode kerning_verdana_40_4bpp[] FONT_KERNING_LOCATION_FLASH_ATTRIBUTE = {
 | 
			
		||||
    { 0, 0 }
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										27
									
								
								TouchGFX/generated/fonts/src/Table_verdana_10_4bpp.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								TouchGFX/generated/fonts/src/Table_verdana_10_4bpp.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,27 @@
 | 
			
		||||
// Autogenerated, do not edit
 | 
			
		||||
 | 
			
		||||
#include <fonts/GeneratedFont.hpp>
 | 
			
		||||
 | 
			
		||||
FONT_TABLE_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const touchgfx::GlyphNode glyphs_verdana_10_4bpp[] FONT_TABLE_LOCATION_FLASH_ATTRIBUTE = {
 | 
			
		||||
    {     0, 0x003F,   5,   8,   8,   0,   5,   0,   0, 0x00 }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// verdana_10_4bpp
 | 
			
		||||
FONT_TABLE_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const touchgfx::GlyphNode glyphs_verdana_10_4bpp[] FONT_TABLE_LOCATION_FLASH_ATTRIBUTE;
 | 
			
		||||
FONT_GLYPH_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const uint8_t unicodes_verdana_10_4bpp_0[] FONT_GLYPH_LOCATION_FLASH_ATTRIBUTE;
 | 
			
		||||
FONT_SEARCHTABLE_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const uint8_t* const unicodes_verdana_10_4bpp[] FONT_SEARCHTABLE_LOCATION_FLASH_ATTRIBUTE = {
 | 
			
		||||
    unicodes_verdana_10_4bpp_0
 | 
			
		||||
};
 | 
			
		||||
FONT_KERNING_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const touchgfx::KerningNode kerning_verdana_10_4bpp[] FONT_KERNING_LOCATION_FLASH_ATTRIBUTE;
 | 
			
		||||
touchgfx::GeneratedFont& getFont_verdana_10_4bpp();
 | 
			
		||||
 | 
			
		||||
touchgfx::GeneratedFont& getFont_verdana_10_4bpp()
 | 
			
		||||
{
 | 
			
		||||
    static touchgfx::GeneratedFont verdana_10_4bpp(glyphs_verdana_10_4bpp, 1, 10, 10, 0, 0, 4, 1, 0, 0, unicodes_verdana_10_4bpp, kerning_verdana_10_4bpp, 63, 0, 0, 0);
 | 
			
		||||
    return verdana_10_4bpp;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										34
									
								
								TouchGFX/generated/fonts/src/Table_verdana_20_4bpp.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								TouchGFX/generated/fonts/src/Table_verdana_20_4bpp.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,34 @@
 | 
			
		||||
// Autogenerated, do not edit
 | 
			
		||||
 | 
			
		||||
#include <fonts/GeneratedFont.hpp>
 | 
			
		||||
 | 
			
		||||
FONT_TABLE_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const touchgfx::GlyphNode glyphs_verdana_20_4bpp[] FONT_TABLE_LOCATION_FLASH_ATTRIBUTE = {
 | 
			
		||||
    {     0, 0x003F,   9,  14,  14,   1,  11,   0,   0, 0x00 },
 | 
			
		||||
    {    70, 0x0042,  12,  14,  14,   1,  14,   0,   0, 0x00 },
 | 
			
		||||
    {   154, 0x0046,  11,  14,  14,   1,  12,   0,   0, 0x00 },
 | 
			
		||||
    {   238, 0x0053,  12,  14,  14,   1,  14,   0,   0, 0x00 },
 | 
			
		||||
    {   322, 0x0054,  13,  14,  14,   0,  12,   0,   2, 0x00 },
 | 
			
		||||
    {   420, 0x0055,  12,  14,  14,   1,  15,   0,   0, 0x00 },
 | 
			
		||||
    {   504, 0x0061,  10,  11,  11,   1,  12,   2,   2, 0x00 },
 | 
			
		||||
    {   559, 0x0065,  10,  11,  11,   1,  12,   4,   1, 0x00 }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// verdana_20_4bpp
 | 
			
		||||
FONT_TABLE_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const touchgfx::GlyphNode glyphs_verdana_20_4bpp[] FONT_TABLE_LOCATION_FLASH_ATTRIBUTE;
 | 
			
		||||
FONT_GLYPH_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const uint8_t unicodes_verdana_20_4bpp_0[] FONT_GLYPH_LOCATION_FLASH_ATTRIBUTE;
 | 
			
		||||
FONT_SEARCHTABLE_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const uint8_t* const unicodes_verdana_20_4bpp[] FONT_SEARCHTABLE_LOCATION_FLASH_ATTRIBUTE = {
 | 
			
		||||
    unicodes_verdana_20_4bpp_0
 | 
			
		||||
};
 | 
			
		||||
FONT_KERNING_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const touchgfx::KerningNode kerning_verdana_20_4bpp[] FONT_KERNING_LOCATION_FLASH_ATTRIBUTE;
 | 
			
		||||
touchgfx::GeneratedFont& getFont_verdana_20_4bpp();
 | 
			
		||||
 | 
			
		||||
touchgfx::GeneratedFont& getFont_verdana_20_4bpp()
 | 
			
		||||
{
 | 
			
		||||
    static touchgfx::GeneratedFont verdana_20_4bpp(glyphs_verdana_20_4bpp, 8, 20, 20, 0, 0, 4, 1, 0, 1, unicodes_verdana_20_4bpp, kerning_verdana_20_4bpp, 63, 0, 0, 0);
 | 
			
		||||
    return verdana_20_4bpp;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										27
									
								
								TouchGFX/generated/fonts/src/Table_verdana_40_4bpp.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								TouchGFX/generated/fonts/src/Table_verdana_40_4bpp.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,27 @@
 | 
			
		||||
// Autogenerated, do not edit
 | 
			
		||||
 | 
			
		||||
#include <fonts/GeneratedFont.hpp>
 | 
			
		||||
 | 
			
		||||
FONT_TABLE_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const touchgfx::GlyphNode glyphs_verdana_40_4bpp[] FONT_TABLE_LOCATION_FLASH_ATTRIBUTE = {
 | 
			
		||||
    {     0, 0x003F,  17,  31,  31,   3,  22,   0,   0, 0x00 }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// verdana_40_4bpp
 | 
			
		||||
FONT_TABLE_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const touchgfx::GlyphNode glyphs_verdana_40_4bpp[] FONT_TABLE_LOCATION_FLASH_ATTRIBUTE;
 | 
			
		||||
FONT_GLYPH_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const uint8_t unicodes_verdana_40_4bpp_0[] FONT_GLYPH_LOCATION_FLASH_ATTRIBUTE;
 | 
			
		||||
FONT_SEARCHTABLE_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const uint8_t* const unicodes_verdana_40_4bpp[] FONT_SEARCHTABLE_LOCATION_FLASH_ATTRIBUTE = {
 | 
			
		||||
    unicodes_verdana_40_4bpp_0
 | 
			
		||||
};
 | 
			
		||||
FONT_KERNING_LOCATION_FLASH_PRAGMA
 | 
			
		||||
KEEP extern const touchgfx::KerningNode kerning_verdana_40_4bpp[] FONT_KERNING_LOCATION_FLASH_ATTRIBUTE;
 | 
			
		||||
touchgfx::GeneratedFont& getFont_verdana_40_4bpp();
 | 
			
		||||
 | 
			
		||||
touchgfx::GeneratedFont& getFont_verdana_40_4bpp()
 | 
			
		||||
{
 | 
			
		||||
    static touchgfx::GeneratedFont verdana_40_4bpp(glyphs_verdana_40_4bpp, 1, 40, 40, 0, 0, 4, 1, 0, 0, unicodes_verdana_40_4bpp, kerning_verdana_40_4bpp, 63, 0, 0, 0);
 | 
			
		||||
    return verdana_40_4bpp;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										152
									
								
								TouchGFX/generated/fonts/src/UnmappedDataFont.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										152
									
								
								TouchGFX/generated/fonts/src/UnmappedDataFont.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,152 @@
 | 
			
		||||
/* DO NOT EDIT THIS FILE */
 | 
			
		||||
/* This file is autogenerated by the text-database code generator */
 | 
			
		||||
 | 
			
		||||
#include <touchgfx/hal/FlashDataReader.hpp>
 | 
			
		||||
#include <fonts/ApplicationFontProvider.hpp>
 | 
			
		||||
#include <fonts/UnmappedDataFont.hpp>
 | 
			
		||||
 | 
			
		||||
namespace touchgfx
 | 
			
		||||
{
 | 
			
		||||
GlyphNode UnmappedDataFont::glyphNodeBuffer;
 | 
			
		||||
 | 
			
		||||
UnmappedDataFont::UnmappedDataFont(const GlyphNode* glyphs, const uint16_t* unicodeList, uint16_t numGlyphs, uint16_t height, uint16_t baseline, uint8_t pixAboveTop, uint8_t pixBelowBottom, uint8_t bitsPerPixel, uint8_t byteAlignRow, uint8_t maxLeft, uint8_t maxRight, const uint8_t* const* glyphDataList, const KerningNode* kerningList, const Unicode::UnicodeChar fallbackChar, const Unicode::UnicodeChar ellipsisChar, const uint16_t* const gsubData, const FontContextualFormsTable* formsTable)
 | 
			
		||||
    : Font(height, baseline, pixAboveTop, pixBelowBottom, bitsPerPixel, byteAlignRow, maxLeft, maxRight, fallbackChar, ellipsisChar),
 | 
			
		||||
      glyphList(glyphs),
 | 
			
		||||
      listSize(numGlyphs),
 | 
			
		||||
      unicodes(unicodeList),
 | 
			
		||||
      glyphDataList(glyphDataList),
 | 
			
		||||
      kerningData(kerningList),
 | 
			
		||||
      gsubTable(gsubData),
 | 
			
		||||
      arabicTable(formsTable)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const GlyphNode* UnmappedDataFont::getGlyph(Unicode::UnicodeChar unicode, const uint8_t*& pixelData, uint8_t& bitsPerPixel) const
 | 
			
		||||
{
 | 
			
		||||
    int index = lookupUnicode(unicode);
 | 
			
		||||
 | 
			
		||||
    if (index != -1)
 | 
			
		||||
    {
 | 
			
		||||
        // Read glyphNode from unmapped flash
 | 
			
		||||
        touchgfx::FlashDataReader* const flashReader = ApplicationFontProvider::getFlashReader();
 | 
			
		||||
        if (flashReader)
 | 
			
		||||
        {
 | 
			
		||||
            flashReader->copyData(glyphList + index, &glyphNodeBuffer, sizeof(GlyphNode));
 | 
			
		||||
 | 
			
		||||
            pixelData = getPixelData(const_cast<const GlyphNode*>(&glyphNodeBuffer));
 | 
			
		||||
            bitsPerPixel = getBitsPerPixel();
 | 
			
		||||
            return &glyphNodeBuffer;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const uint8_t* UnmappedDataFont::getPixelData(const GlyphNode* glyph) const
 | 
			
		||||
{
 | 
			
		||||
    const uint8_t* const* table = (const uint8_t* const*)glyphDataList;
 | 
			
		||||
    return &(table[glyph->unicode / 2048][glyph->dataOffset]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int8_t UnmappedDataFont::getKerning(Unicode::UnicodeChar prevChar, const GlyphNode* glyph) const
 | 
			
		||||
{
 | 
			
		||||
    if (!glyph || glyph->kerningTableSize == 0)
 | 
			
		||||
    {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const KerningNode* kerndata = kerningData + glyph->kerningTablePos();
 | 
			
		||||
    for (uint16_t i = glyph->kerningTableSize; i > 0; i--, kerndata++)
 | 
			
		||||
    {
 | 
			
		||||
        if (prevChar == kerndata->unicodePrevChar)
 | 
			
		||||
        {
 | 
			
		||||
            return kerndata->distance;
 | 
			
		||||
        }
 | 
			
		||||
        if (prevChar < kerndata->unicodePrevChar)
 | 
			
		||||
        {
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int UnmappedDataFont::lookupUnicode(uint16_t unicode) const
 | 
			
		||||
{
 | 
			
		||||
    int32_t min = 0;
 | 
			
		||||
    int32_t max = listSize - 1;
 | 
			
		||||
 | 
			
		||||
    int32_t mid = min + (unicode - unicodes[min]); // Linear up from [min].unicode
 | 
			
		||||
    if (mid < min)
 | 
			
		||||
    {
 | 
			
		||||
        // Unicode < unicodes[min] => not found
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
    if (mid > max)
 | 
			
		||||
    {
 | 
			
		||||
        // Linear up ends too high
 | 
			
		||||
        mid = max - (unicodes[max] - unicode); // Linear down from [max].unicode
 | 
			
		||||
        if (mid > max)
 | 
			
		||||
        {
 | 
			
		||||
            // Unicode > unicodes[max] => not found
 | 
			
		||||
            return -1;
 | 
			
		||||
        }
 | 
			
		||||
        if (mid < min)
 | 
			
		||||
        {
 | 
			
		||||
            // Linear down ends too low, take the middle element
 | 
			
		||||
            mid = (min + max) / 2;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    while (min <= max)
 | 
			
		||||
    {
 | 
			
		||||
        if (unicode == unicodes[mid])
 | 
			
		||||
        {
 | 
			
		||||
            // Found at [mid]
 | 
			
		||||
            return mid;
 | 
			
		||||
        }
 | 
			
		||||
        if (unicode < unicodes[mid])
 | 
			
		||||
        {
 | 
			
		||||
            // Unicode is in lower half
 | 
			
		||||
            max = mid - 1;
 | 
			
		||||
            if (max < min)
 | 
			
		||||
            {
 | 
			
		||||
                // Range is empty => not found
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            // We adjusted max, try linear down from [max].unicode
 | 
			
		||||
            mid = max - (unicodes[max] - unicode);
 | 
			
		||||
            if (mid > max)
 | 
			
		||||
            {
 | 
			
		||||
                // Unicode > [max].unicode => not found
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            if (mid < min)
 | 
			
		||||
            {
 | 
			
		||||
                // Linear down ends too low, take the middle element
 | 
			
		||||
                mid = (min + max) / 2;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            // Unicode is in upper half
 | 
			
		||||
            min = mid + 1;
 | 
			
		||||
            if (min > max)
 | 
			
		||||
            {
 | 
			
		||||
                // Range is empty => not found
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            // We adjusted min, try linear up from [min].unicode
 | 
			
		||||
            mid = min + (unicode - unicodes[min]);
 | 
			
		||||
            if (mid < min)
 | 
			
		||||
            {
 | 
			
		||||
                // Unicode < [min].unicode => not found
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            if (mid > max)
 | 
			
		||||
            {
 | 
			
		||||
                // Linear up ends too high, take the middle element
 | 
			
		||||
                mid = (min + max) / 2;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return -1;
 | 
			
		||||
}
 | 
			
		||||
} // namespace touchgfx
 | 
			
		||||
		Reference in New Issue
	
	Block a user