mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 09:39:43 +01:00
Implement bidi_should_transform()
This now returns true if any of the characters in the text belong to the Arabic or Hebrew alphabet, or are one of the Unicode directional formatting characters. This is just so the bidi machinery doesn't have to run 100% of the time for 100% of the languages. I will also make it so the Arabic language pack, as well as custom levels, have an RTL attribute that always enables bidi (and does things like right-alignment in textboxes and other design-flipping)
This commit is contained in:
parent
822755a75f
commit
45ec77973b
1 changed files with 33 additions and 2 deletions
|
@ -265,8 +265,39 @@ void bidi_destroy(void)
|
|||
|
||||
bool bidi_should_transform(const char* text)
|
||||
{
|
||||
// TODO
|
||||
return true;
|
||||
/* Just as an optimization, only run the whole bidi machinery if the
|
||||
* language is actually an RTL one, _or_ if an RTL character is found. */
|
||||
|
||||
const char* text_ptr = text;
|
||||
uint32_t ch;
|
||||
while ((ch = UTF8_next(&text_ptr)))
|
||||
{
|
||||
// The standard Hebrew and Arabic blocks
|
||||
if (ch >= 0x590 && ch <= 0x77F) return true;
|
||||
|
||||
// Extended Arabic B and A
|
||||
if (ch >= 0x870 && ch <= 0x8FF) return true;
|
||||
|
||||
// LEFT-TO-RIGHT MARK and RIGHT-TO-LEFT MARK
|
||||
if (ch == 0x200E || ch == 0x200F) return true;
|
||||
|
||||
// Some other directional formatting: LRE, RLE, PDF, RLO, LRO
|
||||
if (ch >= 0x202A && ch <= 0x202E) return true;
|
||||
|
||||
// The more recent isolates: LRI, RLI, FSI, PDI
|
||||
if (ch >= 0x2066 && ch <= 0x2069) return true;
|
||||
|
||||
// Hebrew presentation forms
|
||||
if (ch >= 0xFB1D && ch <= 0xFB4F) return true;
|
||||
|
||||
// Arabic presentation forms A
|
||||
if (ch >= 0xFB50 && ch <= 0xFDFF) return true;
|
||||
|
||||
// Arabic presentation forms B
|
||||
if (ch >= 0xFE70 && ch <= 0xFEFE) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* bidi_transform(const char* text)
|
||||
|
|
Loading…
Reference in a new issue