Use TouchGFX
This commit is contained in:
@ -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
|
||||
Reference in New Issue
Block a user