Skip to content

Commit

Permalink
Inverse centered text screen border for RTL
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Daaaav authored and InfoTeddy committed Jan 9, 2024
1 parent d78338f commit f846ba5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion desktop_version/src/Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit f846ba5

Please sign in to comment.