Port 6 upstream PRs (PR #939 was already ported): - #852: Complete HalPowerManager with RAII Lock class, WiFi check in setPowerSaving, skipLoopDelay overrides for ClearCache/OtaUpdate, and power lock in Activity render task loops - #965: Fix paragraph formatting inside list items by tracking listItemUntilDepth to prevent unwanted line breaks - #972: Micro-optimizations: std::move in insertFont, const ref for getDataFromBook parameter - #971: Remove redundant hasPrintableChars pre-rendering pass from EpdFont, EpdFontFamily, and GfxRenderer - #977: Skip unsupported image formats before extraction, add PARSE_BUFFER_SIZE constant and chapter parse timing - #975: Fix UITheme memory leak by replacing raw pointer with std::unique_ptr for currentTheme Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
898 B
C++
30 lines
898 B
C++
#include "EpdFontFamily.h"
|
|
|
|
const EpdFont* EpdFontFamily::getFont(const Style style) const {
|
|
// Extract font style bits (ignore UNDERLINE bit for 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);
|
|
};
|