From fea663ac64cdd56f8937c5347d9ab844de57f245 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Wed, 29 Apr 2026 13:28:26 +0200 Subject: [PATCH] Fix markdown underline / strikethrough omission Co-authored-by: Copilot --- lib/Epub/Epub/blocks/TextBlock.cpp | 8 ++++---- src/activities/reader/MdReaderActivity.cpp | 11 ++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/Epub/Epub/blocks/TextBlock.cpp b/lib/Epub/Epub/blocks/TextBlock.cpp index a2baa39b..f7fde4b2 100644 --- a/lib/Epub/Epub/blocks/TextBlock.cpp +++ b/lib/Epub/Epub/blocks/TextBlock.cpp @@ -37,13 +37,13 @@ void TextBlock::render(const GfxRenderer& renderer, const int fontId, const int } if ((currentStyle & EpdFontFamily::UNDERLINE) != 0) { - const int underlineY = y + renderer.getFontAscenderSize(fontId) + 2; - renderer.drawLine(startX, underlineY, startX + lineWidth, underlineY, true); + const int underlineY = y + renderer.getFontAscenderSize(fontId) + 3; + renderer.drawLine(startX, underlineY, startX + lineWidth, underlineY, 2, true); } if ((currentStyle & EpdFontFamily::STRIKETHROUGH) != 0) { - const int strikeY = y + renderer.getFontAscenderSize(fontId) / 2 + 1; - renderer.drawLine(startX, strikeY, startX + lineWidth, strikeY, true); + const int strikeY = y + renderer.getFontAscenderSize(fontId) / 2 + 2; + renderer.drawLine(startX, strikeY, startX + lineWidth, strikeY, 2, true); } } } diff --git a/src/activities/reader/MdReaderActivity.cpp b/src/activities/reader/MdReaderActivity.cpp index e7dd241a..376d740b 100644 --- a/src/activities/reader/MdReaderActivity.cpp +++ b/src/activities/reader/MdReaderActivity.cpp @@ -728,8 +728,17 @@ void MdReaderActivity::renderPage() { // Render each span for (const auto& span : line.spans) { if (!span.text.empty()) { + const int spanWidth = renderer.getTextAdvanceX(cachedFontId, span.text.c_str(), span.style); renderer.drawText(cachedFontId, x, y, span.text.c_str(), true, span.style); - x += renderer.getTextAdvanceX(cachedFontId, span.text.c_str(), span.style); + if ((span.style & EpdFontFamily::UNDERLINE) != 0) { + const int underlineY = y + renderer.getFontAscenderSize(cachedFontId) + 3; + renderer.drawLine(x, underlineY, x + spanWidth, underlineY, 2, true); + } + if ((span.style & EpdFontFamily::STRIKETHROUGH) != 0) { + const int strikeY = y + renderer.getFontAscenderSize(cachedFontId) / 2 + 2; + renderer.drawLine(x, strikeY, x + spanWidth, strikeY, 2, true); + } + x += spanWidth; } } }