mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-06 23:57:39 +03:00
Allow users to select custom fonts (.epdfont files) from the /.crosspoint/fonts/ directory on the SD card for EPUB/TXT reading. Features: - New FontSelectionActivity for browsing and selecting fonts - SdFont and SdFontFamily classes for loading fonts from SD card - Dynamic font reloading without device reboot - Reader cache invalidation when font changes - Hash-based font ID generation for proper cache management The custom fonts use the .epdfont binary format which supports: - 2-bit antialiasing for smooth text rendering - Efficient on-demand glyph loading with LRU cache - Memory-optimized design for ESP32-C3 constraints
35 lines
1.3 KiB
C++
35 lines
1.3 KiB
C++
#pragma once
|
|
#include "EpdFont.h"
|
|
|
|
class EpdFontFamily {
|
|
public:
|
|
enum Style : uint8_t { REGULAR = 0, BOLD = 1, ITALIC = 2, BOLD_ITALIC = 3 };
|
|
|
|
explicit EpdFontFamily(const EpdFont* regular, const EpdFont* bold = nullptr, const EpdFont* italic = nullptr,
|
|
const EpdFont* boldItalic = nullptr)
|
|
: regular(regular), bold(bold), italic(italic), boldItalic(boldItalic) {}
|
|
~EpdFontFamily() = default;
|
|
void getTextDimensions(const char* string, int* w, int* h, Style style = REGULAR) const;
|
|
bool hasPrintableChars(const char* string, Style style = REGULAR) const;
|
|
const EpdFontData* getData(Style style = REGULAR) const;
|
|
const EpdGlyph* getGlyph(uint32_t cp, Style style = REGULAR) const;
|
|
|
|
// Check if bold variant is available (for synthetic bold decision)
|
|
bool hasBold() const { return bold != nullptr; }
|
|
|
|
private:
|
|
const EpdFont* regular;
|
|
const EpdFont* bold;
|
|
const EpdFont* italic;
|
|
const EpdFont* boldItalic;
|
|
|
|
const EpdFont* getFont(Style style) const;
|
|
};
|
|
|
|
// Global typedef for use outside class scope (needed by SdFontFamily and GfxRenderer)
|
|
using EpdFontStyle = EpdFontFamily::Style;
|
|
constexpr EpdFontStyle REGULAR = EpdFontFamily::REGULAR;
|
|
constexpr EpdFontStyle BOLD = EpdFontFamily::BOLD;
|
|
constexpr EpdFontStyle ITALIC = EpdFontFamily::ITALIC;
|
|
constexpr EpdFontStyle BOLD_ITALIC = EpdFontFamily::BOLD_ITALIC;
|