diff --git a/lib/Epub/Epub/blocks/TextBlock.cpp b/lib/Epub/Epub/blocks/TextBlock.cpp index a9fefb25..3549087e 100644 --- a/lib/Epub/Epub/blocks/TextBlock.cpp +++ b/lib/Epub/Epub/blocks/TextBlock.cpp @@ -19,6 +19,7 @@ void TextBlock::render(const GfxRenderer& renderer, const int fontId, const int return; } + const bool scanning = renderer.isFontCacheScanning(); const int ascender = renderer.getFontAscenderSize(fontId); for (size_t i = 0; i < words.size(); i++) { const int wordX = wordXpos[i] + x; @@ -58,7 +59,7 @@ void TextBlock::render(const GfxRenderer& renderer, const int fontId, const int renderer.drawText(fontId, wordX, wordY, words[i].c_str(), true, currentStyle, baseDir); } - if ((currentStyle & EpdFontFamily::UNDERLINE) != 0) { + if (!scanning && (currentStyle & EpdFontFamily::UNDERLINE) != 0) { const std::string& w = words[i]; const int fullWordWidth = renderer.getTextWidth(fontId, w.c_str(), currentStyle, baseDir); // y is the top of the text line; add ascender to reach baseline, then offset 2px below diff --git a/lib/GfxRenderer/GfxRenderer.cpp b/lib/GfxRenderer/GfxRenderer.cpp index e5246a07..759b2ad4 100644 --- a/lib/GfxRenderer/GfxRenderer.cpp +++ b/lib/GfxRenderer/GfxRenderer.cpp @@ -91,6 +91,8 @@ void GfxRenderer::begin() { bwBufferChunks.assign((frameBufferSize + BW_BUFFER_CHUNK_SIZE - 1) / BW_BUFFER_CHUNK_SIZE, nullptr); } +bool GfxRenderer::isFontCacheScanning() const { return fontCacheManager_ && fontCacheManager_->isScanning(); } + void GfxRenderer::insertFont(const int fontId, EpdFontFamily font) { auto result = fontMap.insert({fontId, font}); if (!result.second) { diff --git a/lib/GfxRenderer/GfxRenderer.h b/lib/GfxRenderer/GfxRenderer.h index 16aa6de9..924e5c0b 100644 --- a/lib/GfxRenderer/GfxRenderer.h +++ b/lib/GfxRenderer/GfxRenderer.h @@ -104,6 +104,7 @@ class GfxRenderer { } void setFontCacheManager(FontCacheManager* m) { fontCacheManager_ = m; } FontCacheManager* getFontCacheManager() const { return fontCacheManager_; } + bool isFontCacheScanning() const; const std::map& getFontMap() const { return fontMap; } void registerSdCardFont(int fontId, SdCardFont* font) { sdCardFonts_[fontId] = font; } void unregisterSdCardFont(int fontId) { removeFont(fontId); }