From a5b76588787c908ca543823163f706505443062f Mon Sep 17 00:00:00 2001 From: Wojciech Kaczmarski <44336093+sp5wwp@users.noreply.github.com> Date: Tue, 14 Jun 2022 15:56:13 +0200 Subject: [PATCH] Fixed bug causing the newline character to misalign text if "TEXT_ALIGN_CENTER" is used with multi-line strings. --- openrtx/src/core/graphics.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/openrtx/src/core/graphics.cpp b/openrtx/src/core/graphics.cpp index 5196f311..ea5058fe 100644 --- a/openrtx/src/core/graphics.cpp +++ b/openrtx/src/core/graphics.cpp @@ -439,7 +439,15 @@ point_t gfx_printBuffer(point_t start, fontSize_t size, textAlign_t alignment, // Handle newline and carriage return if (c == '\n') { - start.x = reset_x; + if(alignment!=TEXT_ALIGN_CENTER) + { + start.x = reset_x; + } + else + { + line_size = get_line_size(f, &buf[i+1], len-(i+1)); + start.x = reset_x = get_reset_x(alignment, line_size, start.x); + } start.y += f.yAdvance; continue; }