diff --git a/src/Asset.cpp b/src/Asset.cpp index 09c3825..c228739 100644 --- a/src/Asset.cpp +++ b/src/Asset.cpp @@ -428,6 +428,14 @@ class ResourceGlyph : public GlyphObject /* ResourceTypeface */ +GlyphBlock ResourceTypeface::getBlock(unsigned index) const +{ + if(index < FSTR::readValue(&typeface.numBlocks)) { + return FSTR::readValue(&typeface.blocks[index]); + } + return GlyphBlock{}; +} + bool ResourceTypeface::findGlyph(uint16_t codePoint, Resource::GlyphResource& glyph) const { auto glyphPtr = typeface.glyphs; diff --git a/src/include/Graphics/Asset.h b/src/include/Graphics/Asset.h index 9de6446..62792a3 100644 --- a/src/include/Graphics/Asset.h +++ b/src/include/Graphics/Asset.h @@ -512,6 +512,7 @@ class TextOptions : public Meta } }; +using GlyphBlock = Resource::GlyphBlock; using GlyphOptions = TextOptions; /** @@ -522,6 +523,23 @@ class TypeFace : public AssetTemplate public: using AssetTemplate::AssetTemplate; + /** + * @brief Return any device-specific information + * + * Controllers with internal fonts return private structures here to support rendering. + */ + virtual const void* getDeviceData() const + { + return nullptr; + } + + /** + * @brief Support enumeration of codepoint ranges + * @param index Zero-based index of glyph block to return + * @retval GlyphBlock + */ + virtual GlyphBlock getBlock(unsigned index) const = 0; + /** * @brief Style of this typeface (bold, italic, etc.) */ @@ -613,6 +631,8 @@ class ResourceTypeface : public Graphics::TypeFace { } + GlyphBlock getBlock(unsigned index) const override; + FontStyles getStyle() const override { Resource::TypefaceResource::Format format{ diff --git a/src/include/Graphics/LcdFont.h b/src/include/Graphics/LcdFont.h index d7b4c93..244f2ad 100644 --- a/src/include/Graphics/LcdFont.h +++ b/src/include/Graphics/LcdFont.h @@ -46,6 +46,14 @@ class LcdGlyph : public GlyphObject class LcdTypeFace : public TypeFace { public: + GlyphBlock getBlock(unsigned index) const override + { + if(index == 0) { + return GlyphBlock{0, 255}; + } + return GlyphBlock{}; + } + FontStyles getStyle() const override { return 0;