mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 07:07:38 +03:00
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <SDCardManager.h>
|
|
|
|
#include <vector>
|
|
|
|
#include "EpdFont.h"
|
|
|
|
struct BitmapCacheEntry {
|
|
uint32_t codePoint = 0;
|
|
uint32_t lastAccess = 0;
|
|
uint8_t* data = nullptr;
|
|
uint16_t size = 0;
|
|
};
|
|
|
|
struct GlyphStructCacheEntry {
|
|
uint32_t codePoint = 0xFFFFFFFF; // Invalid initial value
|
|
uint32_t lastAccess = 0;
|
|
EpdGlyph glyph;
|
|
};
|
|
|
|
class CustomEpdFont : public EpdFont {
|
|
public:
|
|
CustomEpdFont(const String& filePath, const EpdFontData* data, uint32_t offsetIntervals, uint32_t offsetGlyphs,
|
|
uint32_t offsetBitmaps);
|
|
~CustomEpdFont() override;
|
|
|
|
const EpdGlyph* getGlyph(uint32_t cp, const EpdFontStyles::Style style = EpdFontStyles::REGULAR) const override;
|
|
const uint8_t* loadGlyphBitmap(const EpdGlyph* glyph, uint8_t* buffer,
|
|
const EpdFontStyles::Style style = EpdFontStyles::REGULAR) const override;
|
|
|
|
private:
|
|
String filePath;
|
|
mutable FsFile fontFile;
|
|
uint32_t offsetIntervals;
|
|
uint32_t offsetGlyphs;
|
|
uint32_t offsetBitmaps;
|
|
|
|
// Bitmap Cache (Pixel data)
|
|
static constexpr size_t BITMAP_CACHE_CAPACITY = 10;
|
|
mutable BitmapCacheEntry bitmapCache[BITMAP_CACHE_CAPACITY];
|
|
|
|
// Glyph Struct Cache (Metadata)
|
|
static constexpr size_t GLYPH_CACHE_CAPACITY = 200;
|
|
mutable GlyphStructCacheEntry glyphCache[GLYPH_CACHE_CAPACITY];
|
|
|
|
mutable uint32_t currentAccessCount = 0;
|
|
|
|
void clearCache() const;
|
|
};
|