1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00

Fix fallback (english) texts with hebrew locale

This commit is contained in:
Mathieu Schroeter 2019-02-09 22:37:49 +01:00
parent e60568bdcf
commit f28a0c61bd

View File

@ -190,9 +190,16 @@ DrawText (
Sint32 start = pos.y; Sint32 start = pos.y;
Sint32 rel = 0; Sint32 rel = 0;
auto useD7 = strchr (pText, 0xD7) != nullptr;
auto isRightReading = useD7 && IsRightReading ();
auto length = strlen (pText);
if (length >= 1 && !useD7 && IsRightReading ())
pos.x -= GetTextWidth (pText, font);
while (*pText != '\0' || skip) while (*pText != '\0' || skip)
{ {
if (IsRightReading () && numberSize == 0) if (isRightReading && numberSize == 0)
{ {
it = pText; it = pText;
isNumber = *pText >= '0' && *pText <= '9'; isNumber = *pText >= '0' && *pText <= '9';
@ -214,7 +221,7 @@ DrawText (
rank = GetOffset (pText); rank = GetOffset (pText);
if (IsRightReading ()) if (isRightReading)
{ {
if (rank == '(') if (rank == '(')
rank = ')'; rank = ')';
@ -225,7 +232,7 @@ DrawText (
auto inc = rank > 127; auto inc = rank > 127;
auto lg = GetCharWidth (pText, font); auto lg = GetCharWidth (pText, font);
if (IsRightReading ()) if (isRightReading)
pos.x += -lg; pos.x += -lg;
rel += lg; rel += lg;
@ -240,7 +247,7 @@ DrawText (
else else
pPixmap->DrawIcon (-1, CHLITTLE, rank, pos); pPixmap->DrawIcon (-1, CHLITTLE, rank, pos);
if (!IsRightReading ()) if (!isRightReading)
pos.x += lg; pos.x += lg;
if (!numberSize && skip > 0) if (!numberSize && skip > 0)
@ -321,6 +328,7 @@ DrawTextCenter (CPixmap * pPixmap, Point pos, const char * pText, Sint32 font)
char * pDest; char * pDest;
Sint32 itl; Sint32 itl;
Point start; Point start;
auto isRightReading = IsRightReading ();
if (font == FONTLITTLE) if (font == FONTLITTLE)
itl = DIMLITTLEY; itl = DIMLITTLEY;
@ -341,7 +349,7 @@ DrawTextCenter (CPixmap * pPixmap, Point pos, const char * pText, Sint32 font)
pDest = text; pDest = text;
start.x = start.x =
pos.x + pos.x +
(IsRightReading () ? GetTextWidth (pDest) : -GetTextWidth (pDest)) / 2; (isRightReading ? GetTextWidth (pDest) : -GetTextWidth (pDest)) / 2;
start.y = pos.y; start.y = pos.y;
DrawText (pPixmap, start, pDest, font); DrawText (pPixmap, start, pDest, font);