From 8d4cfde809cc2e36746af7356dced7f9049c47f2 Mon Sep 17 00:00:00 2001 From: Eliz Kilic Date: Fri, 23 Jan 2026 23:48:34 +0000 Subject: [PATCH] fix render issue --- lib/GfxRenderer/GfxRenderer.cpp | 6 ++++++ lib/GfxRenderer/GfxRenderer.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/lib/GfxRenderer/GfxRenderer.cpp b/lib/GfxRenderer/GfxRenderer.cpp index 08420bf9..6baf41a5 100644 --- a/lib/GfxRenderer/GfxRenderer.cpp +++ b/lib/GfxRenderer/GfxRenderer.cpp @@ -83,6 +83,12 @@ void GfxRenderer::drawCenteredText(const int fontId, const int y, const char* te drawText(fontId, x, y, text, black, style); } +void GfxRenderer::drawCenteredText(const int fontId, const int y, const char* text, const bool black, const int x, + const int width, const EpdFontFamily::Style style) const { + const int text_x = x + (width - getTextWidth(fontId, text, style)) / 2; + drawText(fontId, text_x, y, text, black, style); +} + void GfxRenderer::drawText(const int fontId, const int x, const int y, const char* text, const bool black, const EpdFontFamily::Style style) const { const int yPos = y + getFontAscenderSize(fontId); diff --git a/lib/GfxRenderer/GfxRenderer.h b/lib/GfxRenderer/GfxRenderer.h index b1fea69b..b302c05a 100644 --- a/lib/GfxRenderer/GfxRenderer.h +++ b/lib/GfxRenderer/GfxRenderer.h @@ -75,6 +75,8 @@ class GfxRenderer { int getTextWidth(int fontId, const char* text, EpdFontFamily::Style style = EpdFontFamily::REGULAR) const; void drawCenteredText(int fontId, int y, const char* text, bool black = true, EpdFontFamily::Style style = EpdFontFamily::REGULAR) const; + void drawCenteredText(int fontId, int y, const char* text, bool black, int x, int width, + EpdFontFamily::Style style = EpdFontFamily::REGULAR) const; 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;