Add drawCenteredText to GfxRenderer

This commit is contained in:
Dave Allie
2025-12-08 22:52:19 +11:00
parent 07cc589e59
commit 02b157c02b
7 changed files with 19 additions and 21 deletions

View File

@@ -198,8 +198,7 @@ void EpubReaderScreen::renderScreen() {
if (section->pageCount == 0) {
Serial.printf("[%lu] [ERS] No pages to render\n", millis());
const int width = renderer.getTextWidth(READER_FONT_ID, "Empty chapter", BOLD);
renderer.drawText(READER_FONT_ID, (GfxRenderer::getScreenWidth() - width) / 2, 300, "Empty chapter", true, BOLD);
renderer.drawCenteredText(READER_FONT_ID, 300, "Empty chapter", true, BOLD);
renderStatusBar();
renderer.displayBuffer();
return;
@@ -207,8 +206,7 @@ void EpubReaderScreen::renderScreen() {
if (section->currentPage < 0 || section->currentPage >= section->pageCount) {
Serial.printf("[%lu] [ERS] Page out of bounds: %d (max %d)\n", millis(), section->currentPage, section->pageCount);
const int width = renderer.getTextWidth(READER_FONT_ID, "Out of bounds", BOLD);
renderer.drawText(READER_FONT_ID, (GfxRenderer::getScreenWidth() - width) / 2, 300, "Out of bounds", true, BOLD);
renderer.drawCenteredText(READER_FONT_ID, 300, "Out of bounds", true, BOLD);
renderStatusBar();
renderer.displayBuffer();
return;