-
Notifications
You must be signed in to change notification settings - Fork 9k
Description
Description of the new feature
What's the safe solution?
We enable RTL only if the text is Arabic (by default)
We add code that checks: Does the line contain RTL characters (such as Arabic)
This is the best balance between supporting Arabic and preserving the rest of the functionality
to fix this issues
A function that checks if the text contains Arabic letters.
bool ContainsArabic(const std::wstring& text)
{
for (wchar_t ch : text)
{
if ((ch >= 0x0600 && ch <= 0x06FF) || // Arabic
(ch >= 0x0750 && ch <= 0x077F) || // Arabic Supplement
(ch >= 0x08A0 && ch <= 0x08FF)) // Arabic Extended
{
return true;
}
}
return false;
}
if (ContainsArabic(text))
{
layout->SetReadingDirection(DWRITE_READING_DIRECTION_RIGHT_TO_LEFT);
layout->SetFlowDirection(DWRITE_FLOW_DIRECTION_RIGHT_TO_LEFT);
}
The contains Arabic function checks for Unicode between \u0600 to \u06FF.
Good Luck The biggest company in the world don't have solution for RTL Text Issue 😎
Proposed technical implementation details
No response