mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 06:37:38 +03:00
Convert Style enum to true bitflags by adding UNDERLINE=4. Update getFont() to use bitwise operations instead of equality checks, allowing styles like BOLD|UNDERLINE to work correctly. This is preparation for encoding underline state directly in the Style rather than tracking it separately.
34 lines
1.0 KiB
C++
34 lines
1.0 KiB
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);
|
|
}
|
|
|
|
bool EpdFontFamily::hasPrintableChars(const char* string, const Style style) const {
|
|
return getFont(style)->hasPrintableChars(string);
|
|
}
|
|
|
|
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);
|
|
};
|