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.
This commit is contained in:
Dav999 2024-01-08 04:59:08 +01:00 committed by Misa Elizabeth Kai
parent d78338f9ef
commit f846ba5d59
1 changed files with 10 additions and 1 deletions

View File

@ -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
{