From 53931b3693febc31e5ad62556361196322950ebd Mon Sep 17 00:00:00 2001 From: Jake Kenneally Date: Tue, 3 Feb 2026 19:39:58 -0500 Subject: [PATCH] feat: add UNDERLINE bitflag to EpdFontFamily::Style 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. --- lib/EpdFont/EpdFontFamily.cpp | 24 ++++++++++-------------- lib/EpdFont/EpdFontFamily.h | 2 +- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/EpdFont/EpdFontFamily.cpp b/lib/EpdFont/EpdFontFamily.cpp index 74a6677f..821153e3 100644 --- a/lib/EpdFont/EpdFontFamily.cpp +++ b/lib/EpdFont/EpdFontFamily.cpp @@ -1,23 +1,19 @@ #include "EpdFontFamily.h" const EpdFont* EpdFontFamily::getFont(const Style style) const { - if (style == BOLD && bold) { + // 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; - } - if (style == ITALIC && italic) { + } else if (hasItalic && italic) { return italic; } - if (style == BOLD_ITALIC) { - if (boldItalic) { - return boldItalic; - } - if (bold) { - return bold; - } - if (italic) { - return italic; - } - } return regular; } diff --git a/lib/EpdFont/EpdFontFamily.h b/lib/EpdFont/EpdFontFamily.h index 92043d1f..64fd9953 100644 --- a/lib/EpdFont/EpdFontFamily.h +++ b/lib/EpdFont/EpdFontFamily.h @@ -3,7 +3,7 @@ class EpdFontFamily { public: - enum Style : uint8_t { REGULAR = 0, BOLD = 1, ITALIC = 2, BOLD_ITALIC = 3 }; + enum Style : uint8_t { REGULAR = 0, BOLD = 1, ITALIC = 2, BOLD_ITALIC = 3, UNDERLINE = 4 }; explicit EpdFontFamily(const EpdFont* regular, const EpdFont* bold = nullptr, const EpdFont* italic = nullptr, const EpdFont* boldItalic = nullptr)