1
0

add screen library

This commit is contained in:
2024-01-13 19:15:18 +01:00
parent 7b660f0fe2
commit 65ff5de90f
533 changed files with 113575 additions and 2 deletions

View File

@ -0,0 +1,38 @@
/* DO NOT EDIT THIS FILE */
/* This file is autogenerated by the text-database code generator */
#ifndef APPLICATIONFONTPROVIDER_HPP
#define 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 // APPLICATIONFONTPROVIDER_HPP

View File

@ -0,0 +1,71 @@
/* DO NOT EDIT THIS FILE */
/* This file is autogenerated by the text-database code generator */
#ifndef CACHEDFONT_HPP
#define CACHEDFONT_HPP
#include <fonts/GeneratedFont.hpp>
#include <fonts/FontCache.hpp>
namespace touchgfx
{
class CachedFont : public GeneratedFont
{
public:
CachedFont(const struct touchgfx::BinaryFontData* data, FontId id, FontCache* _cache, const GeneratedFont* _flashFont)
: GeneratedFont(0, //GlyphNode*
data->numberOfGlyphs,
data->height,
data->pixBelowBase,
data->bitsPerPixel,
data->byteAlignRow,
data->maxLeft,
data->maxRight,
0, //glyphDataPointer
0, //Kerning table not used for cached font
data->fallbackChar,
data->ellipsisChar,
0), //gsubTablePointer
fontId(id),
cache(_cache),
flashFont(_flashFont)
{}
CachedFont() : GeneratedFont() {}
using GeneratedFont::getGlyph;
virtual const GlyphNode* getGlyph(Unicode::UnicodeChar unicode, const uint8_t*& pixelData, uint8_t& bitsPerPixel) const;
virtual const uint8_t* getPixelData(const GlyphNode* glyph) const;
virtual int8_t getKerning(Unicode::UnicodeChar prevChar, const GlyphNode* glyph) const;
void setFontCache(FontCache& cache);
FontId getFontId() const
{
return fontId;
}
virtual const uint16_t* getGSUBTable() const
{
if (gsubTable != 0)
{
return gsubTable;
}
return flashFont->getGSUBTable();
}
virtual void setGSUBTable(const uint16_t* table)
{
gsubTable = table;
}
private:
FontId fontId;
FontCache* cache;
const GeneratedFont* flashFont;
};
} // namespace touchgfx
#endif // CACHEDFONT_HPP

View File

@ -0,0 +1,94 @@
/* DO NOT EDIT THIS FILE */
/* This file is autogenerated by the text-database code generator */
#ifndef FONTCACHE_HPP
#define FONTCACHE_HPP
#include <fonts/ApplicationFontProvider.hpp>
#include <touchgfx/Font.hpp>
#include <touchgfx/TypedText.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 keepGsubTable = false);
void setMemory(uint8_t* memory, uint32_t size);
void initializeCachedFont(TypedText t, CachedFont* font, bool loadGsubTable = 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; //first 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 // FONTCACHE_HPP

View File

@ -0,0 +1,133 @@
/* DO NOT EDIT THIS FILE */
/* This file is autogenerated by the text-database code generator */
#ifndef GENERATEDFONT_HPP
#define GENERATEDFONT_HPP
#include <touchgfx/ConstFont.hpp>
namespace touchgfx
{
/**
* An GeneratedFont has both glyph table and glyph data placed in a flash which
* supports random access read (i.e. not a NAND flash)
*
* @see ConstFont
*/
class GeneratedFont : public ConstFont
{
public:
/**
* Construct the GeneratedFont.
*
* @param list The array of glyphs known to this font.
* @param size The number of glyphs in list.
* @param height The height in pixels of the highest character in this font.
* @param pixBelowBase The maximum number of pixels that can be drawn below the
* baseline 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 glyphDataInternalFlash Pointer to the glyph data for the font, placed in internal
* flash.
* @param kerningList pointer to the kerning data for the font, placed in internal
* flash.
* @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.
*/
GeneratedFont(const GlyphNode* list, uint16_t size, uint16_t height, uint8_t pixBelowBase, 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);
using ConstFont::getGlyph;
/**
* Obtains a RAM-based pointer to the pixel data for the specified glyph.
*
* @param glyph The glyph to get the pixels data of.
*
* @return 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;
}
protected:
GeneratedFont() : ConstFont(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), glyphData(0), kerningData(0), gsubTable(0) { }
const void* glyphData; ///< Information describing the glyphs
const KerningNode* kerningData; ///< Information describing the kerning
const uint16_t* gsubTable; ///< Information describing the GSUB tables
};
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[]
uint16_t numberOfGlyphs; // Number of glyphs in Table and Glyphs
uint16_t height; // Font height from base
uint8_t pixBelowBase; // Max pixels below base
uint8_t bitsPerPixel: 7; // Bpp
uint8_t byteAlignRow: 1; // A4/A2/A1
uint8_t maxLeft; // The maximum a character extends to the left
uint8_t maxRight; // The maximum a character 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->height,
data->pixBelowBase,
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)),
glyphData((const uint8_t*)data + data->offsetToGlyphs)
{
}
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;
};
} // namespace touchgfx
#endif // GENERATEDFONT_HPP

View File

@ -0,0 +1,109 @@
/* DO NOT EDIT THIS FILE */
/* This file is autogenerated by the text-database code generator */
#ifndef UNMAPPEDDATAFONT_HPP
#define 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 list The array of glyphs known to this font (indirect).
* @param unicodes The array of unicodes known to this font (direct).
* @param size The number of glyphs in list.
* @param height The height in pixels of the highest character in this font.
* @param pixBelowBase The maximum number of pixels that can be drawn below the
* baseline 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* list, const uint16_t* unicodes, uint16_t size, uint16_t height, uint8_t pixBelowBase, 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);
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;
}
protected:
UnmappedDataFont() : Font(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; ///< Information describing the glyphs (list of pointers)
const KerningNode* kerningData; ///< Information describing the kerning
const uint16_t* gsubTable; ///< Information describing the GSUB tables
static GlyphNode glyphNodeBuffer; ///< Buffer for GlyphNodes read from unmapped flash
};
} // namespace touchgfx
#endif // UNMAPPEDDATAFONT_HPP