Document migration plan from CrossPoint's lib/Epub to FreeInkBook, a memory-efficient clean-room EPUB engine. Covers advantages (O(paragraph+page) memory via SAX parsing, arena allocation, host-testable, full UAX#14 typography, runtime TTF/OTF support), 9-step migration strategy, ESP32-C3 constraints, and integration approach preserving existing UI layer while replacing parsing/layout stack.
33 lines
1.3 KiB
C++
33 lines
1.3 KiB
C++
#pragma once
|
|
#include "EpdFontData.h"
|
|
|
|
class EpdFont {
|
|
void getTextBounds(const char* string, int startX, int startY, int* minX, int* minY, int* maxX, int* maxY) const;
|
|
|
|
public:
|
|
const EpdFontData* data;
|
|
explicit EpdFont(const EpdFontData* data) : data(data) {}
|
|
~EpdFont() = default;
|
|
void getTextDimensions(const char* string, int* w, int* h) const;
|
|
|
|
const EpdGlyph* getGlyph(uint32_t cp) const;
|
|
|
|
/// True when the font actually provides `cp` (interval table or on-demand
|
|
/// SD load) — unlike getGlyph(), never satisfied by the replacement glyph.
|
|
/// Used by layout shaping to decide whether a substitution (ligature,
|
|
/// Arabic presentation form) can really be drawn.
|
|
bool hasGlyph(uint32_t cp) const;
|
|
|
|
/// Returns the kerning adjustment (4.4 fixed-point in pixels) between two codepoints.
|
|
/// Returns 0 if no kerning data exists for the pair.
|
|
int8_t getKerning(uint32_t leftCp, uint32_t rightCp) const;
|
|
|
|
/// Returns the ligature codepoint for a pair, or 0 if no ligature exists.
|
|
uint32_t getLigature(uint32_t leftCp, uint32_t rightCp) const;
|
|
|
|
/// Greedily applies ligature substitutions starting from cp, consuming
|
|
/// as many following codepoints from text as possible. Returns the
|
|
/// (possibly substituted) codepoint; advances text past consumed chars.
|
|
uint32_t applyLigatures(uint32_t cp, const char*& text) const;
|
|
};
|