Implements layout-independent bookmarks using character offsets within chapters instead of percentage-based positions. This allows bookmarks to restore to the exact position regardless of font size or orientation changes. Adds TOC navigation helpers, book progress calculation based on spine item sizes, and a NONE BidiBaseDir option for pre-reordered text. Legacy bookmarks without character offsets fall back to percentage-based positioning.
44 lines
1.5 KiB
C++
44 lines
1.5 KiB
C++
#include "EpdFontFamily.h"
|
|
|
|
const EpdFont* EpdFontFamily::getFont(const Style style) const {
|
|
// Extract font style bits; render-time overlay bits do not affect font selection.
|
|
const bool hasBold = (style & BOLD) != 0;
|
|
const bool hasItalic = (style & ITALIC) != 0;
|
|
|
|
if (hasBold && hasItalic) {
|
|
if (boldItalic) return boldItalic;
|
|
if (bold) return bold;
|
|
if (italic) return italic;
|
|
} else if (hasBold && bold) {
|
|
return bold;
|
|
} else if (hasItalic && italic) {
|
|
return italic;
|
|
}
|
|
|
|
return regular;
|
|
}
|
|
|
|
void EpdFontFamily::getTextDimensions(const char* string, int* w, int* h, const Style style) const {
|
|
getFont(style)->getTextDimensions(string, w, h);
|
|
}
|
|
|
|
const EpdFontData* EpdFontFamily::getData(const Style style) const { return getFont(style)->data; }
|
|
|
|
const EpdGlyph* EpdFontFamily::getGlyph(const uint32_t cp, const Style style) const {
|
|
return getFont(style)->getGlyph(cp);
|
|
}
|
|
|
|
bool EpdFontFamily::hasGlyph(const uint32_t cp, const Style style) const { return getFont(style)->hasGlyph(cp); }
|
|
|
|
int8_t EpdFontFamily::getKerning(const uint32_t leftCp, const uint32_t rightCp, const Style style) const {
|
|
return getFont(style)->getKerning(leftCp, rightCp);
|
|
}
|
|
|
|
uint32_t EpdFontFamily::getLigature(const uint32_t leftCp, const uint32_t rightCp, const Style style) const {
|
|
return getFont(style)->getLigature(leftCp, rightCp);
|
|
}
|
|
|
|
uint32_t EpdFontFamily::applyLigatures(const uint32_t cp, const char*& text, const Style style) const {
|
|
return getFont(style)->applyLigatures(cp, text);
|
|
}
|