Arabic ligatures are also converted, from a table given by Montassar (one of our Arabic translators)
Automatic wordwrapping works properly without further changes (Arabic uses spaces, and we do convert the logical ordering to visual ordering)
To provide a fast path when printing text for LTR languages (and less chance of unexpected breakage of existing content), all the bidi and reshaping machinery will only run for a printed string if one of the following is true:
Printing interface text while the current language has the <rtl> property set
Printing custom level-specific text while the level has the <rtl> property set
The string contains characters in Unicode blocks for the Arabic or Hebrew alphabets, or directional control characters (like the famous U+202E).
The mentioned <rtl> properties also control things like right-alignment in textboxes
An Arabic font (made by Montassar) is added as font_ar (this is an 8x10 font, and it doesn't have Latin characters itself, so I copied 00-FF from Space Station just so we don't duplicate everything, just the important stuff)
Changes made to print flags:
PR_FONT_IDX(idx) now has two arguments: PR_FONT_IDX(idx,rtl). Since PR_FONT_INTERFACE (0) sets the RTL printflag based on the current language, PR_FONT_LEVEL sets it based on the current level, and PR_FONT_8X8 sets it disabled, PR_FONT_IDX requires you to provide whether RTL mode should be enabled. This was always just a simple filling in based on information we had at hand anyway since we got the font index from either the language metadata or level metadata.
PR_RTL_FORCE exists now (it's just set internally by PR_FONT_IDX)
PR_RTL_XFLIP lets you mirror the X axis specifically in RTL languages, so the left border is 320 and the right border is 0, and invert the meaning of PR_LEFT (0) and PR_RIGHT. Most of the time this is not necessary, it's just for stuff where a label is followed by a different print, like "Font: " followed by the font name, time trial time displays, etc. This is also used for the menus.
Just like the setfont(font) scripting command was added to change <font> during playtime, in parallel, now that <rtl> was added, I added the scripting command setrtl(on/off).
Whew, that was everything I think! Time for some screenshots:
By submitting this pull request, I confirm that...
[x] My changes may be used in a future commercial release of VVVVVV
[x] I will be credited in a CONTRIBUTORS file and the "GitHub Friends"
section of the credits for all of said releases, but will NOT be compensated
for these changes
Changes:
As mentioned in https://github.com/TerryCavanagh/VVVVVV/issues/829#issuecomment-1875175582, we're aiming to get Arabic in for 2.4.0, which is a language that needs some significant technical changes! Luckily those happened fairly quickly and painlessly.
<rtl>
property set<rtl>
property set<rtl>
properties also control things like right-alignment in textboxesfont_ar
(this is an 8x10 font, and it doesn't have Latin characters itself, so I copied 00-FF from Space Station just so we don't duplicate everything, just the important stuff)PR_FONT_IDX(idx)
now has two arguments:PR_FONT_IDX(idx,rtl)
. SincePR_FONT_INTERFACE
(0) sets the RTL printflag based on the current language,PR_FONT_LEVEL
sets it based on the current level, and PR_FONT_8X8 sets it disabled,PR_FONT_IDX
requires you to provide whether RTL mode should be enabled. This was always just a simple filling in based on information we had at hand anyway since we got the font index from either the language metadata or level metadata.PR_RTL_FORCE
exists now (it's just set internally byPR_FONT_IDX
)PR_RTL_XFLIP
lets you mirror the X axis specifically in RTL languages, so the left border is 320 and the right border is 0, and invert the meaning ofPR_LEFT
(0) andPR_RIGHT
. Most of the time this is not necessary, it's just for stuff where a label is followed by a different print, like "Font: " followed by the font name, time trial time displays, etc. This is also used for the menus.setfont(font)
scripting command was added to change<font>
during playtime, in parallel, now that<rtl>
was added, I added the scripting commandsetrtl(on/off)
.Whew, that was everything I think! Time for some screenshots:
A random Arabic sentence:![Viridian saying أحتاج مثالا فيه جملة طويلة جدا لا تتسع لها النافذة وتفيض من الصندوق.](https://github.com/TerryCavanagh/VVVVVV/assets/44736680/d7dc796d-8e77-410f-9609-24fc8fd64c97)
Lots of ligatures and right-alignment:![Viridian saying أنا هنا آمنا. وئام لئام لا كلام لأحزان زالت وراء شراء ناي بناء يا عيال الخير للطير مللت مالي باءت القباء للوباء للا للأ للإ للآ لا لأ لإ لآ.](https://github.com/TerryCavanagh/VVVVVV/assets/44736680/6e280bf1-bdae-4107-a6b0-2e874fe65cb8)
A right-to-left menu, and user input:
https://github.com/TerryCavanagh/VVVVVV/assets/44736680/bdf666f7-adbc-46d7-b28a-51e03f6612c4
Legal Stuff:
By submitting this pull request, I confirm that...
CONTRIBUTORS
file and the "GitHub Friends" section of the credits for all of said releases, but will NOT be compensated for these changes