From 9d58952ba74701950de4b2be29a1f55a705a03e5 Mon Sep 17 00:00:00 2001 From: Jake Kenneally Date: Tue, 3 Feb 2026 19:39:25 -0500 Subject: [PATCH] refactor: rename getIndentWidth to getTextAdvanceX The function measures the advance width of arbitrary text (specifically em-space prefix), not just indentation. getTextAdvanceX better reflects its actual purpose. --- lib/Epub/Epub/blocks/TextBlock.cpp | 2 +- lib/GfxRenderer/GfxRenderer.cpp | 2 +- lib/GfxRenderer/GfxRenderer.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Epub/Epub/blocks/TextBlock.cpp b/lib/Epub/Epub/blocks/TextBlock.cpp index 3fd027fe..724471b6 100644 --- a/lib/Epub/Epub/blocks/TextBlock.cpp +++ b/lib/Epub/Epub/blocks/TextBlock.cpp @@ -33,7 +33,7 @@ void TextBlock::render(const GfxRenderer& renderer, const int fontId, const int if (w.size() >= 3 && static_cast(w[0]) == 0xE2 && static_cast(w[1]) == 0x80 && static_cast(w[2]) == 0x83) { const char* visiblePtr = w.c_str() + 3; - const int prefixWidth = renderer.getIndentWidth(fontId, std::string("\xe2\x80\x83").c_str()); + const int prefixWidth = renderer.getTextAdvanceX(fontId, std::string("\xe2\x80\x83").c_str()); const int visibleWidth = renderer.getTextWidth(fontId, visiblePtr, *wordStylesIt); startX = wordX + prefixWidth; underlineWidth = visibleWidth; diff --git a/lib/GfxRenderer/GfxRenderer.cpp b/lib/GfxRenderer/GfxRenderer.cpp index a7019230..40caf18c 100644 --- a/lib/GfxRenderer/GfxRenderer.cpp +++ b/lib/GfxRenderer/GfxRenderer.cpp @@ -470,7 +470,7 @@ int GfxRenderer::getSpaceWidth(const int fontId) const { return fontMap.at(fontId).getGlyph(' ', EpdFontFamily::REGULAR)->advanceX; } -int GfxRenderer::getIndentWidth(const int fontId, const char* text) const { +int GfxRenderer::getTextAdvanceX(const int fontId, const char* text) const { if (fontMap.count(fontId) == 0) { Serial.printf("[%lu] [GFX] Font %d not found\n", millis(), fontId); return 0; diff --git a/lib/GfxRenderer/GfxRenderer.h b/lib/GfxRenderer/GfxRenderer.h index 28c6e475..66d625f5 100644 --- a/lib/GfxRenderer/GfxRenderer.h +++ b/lib/GfxRenderer/GfxRenderer.h @@ -78,7 +78,7 @@ class GfxRenderer { void drawText(int fontId, int x, int y, const char* text, bool black = true, EpdFontFamily::Style style = EpdFontFamily::REGULAR) const; int getSpaceWidth(int fontId) const; - int getIndentWidth(int fontId, const char* text) const; + int getTextAdvanceX(int fontId, const char* text) const; int getFontAscenderSize(int fontId) const; int getLineHeight(int fontId) const; std::string truncatedText(int fontId, const char* text, int maxWidth,