From f846ba5d59a1400f3cdaae1fcacb635bd8a72c86 Mon Sep 17 00:00:00 2001 From: Dav999 Date: Mon, 8 Jan 2024 04:59:08 +0100 Subject: [PATCH] Inverse centered text screen border for RTL If text is set to be centered, but is so long that it starts running offscreen on both sides, the print function instead makes the text start no further left than the left border of the screen (x=0). This is because text running offscreen at the end only is more readable and looks less sloppy than running offscreen at both sides. For RTL, the opposite applies, so it now also works oppositely for RTL prints, where centered strings will only run offscreen on the left side of the screen. --- desktop_version/src/Font.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/Font.cpp b/desktop_version/src/Font.cpp index cc64dadd..cf47a176 100644 --- a/desktop_version/src/Font.cpp +++ b/desktop_version/src/Font.cpp @@ -1290,7 +1290,16 @@ void print( { x = SCREEN_WIDTH_PIXELS / 2; } - x = SDL_max(x - textlen/2, 0); + x -= textlen/2; + + if (!pf.rtl) + { + x = SDL_max(x, 0); + } + else + { + x = SDL_min(x, SCREEN_WIDTH_PIXELS - textlen); + } } else {