Skip to content

Safe solution fix issues RTL Text in Windows Terminal #18887

@n-mr

Description

@n-mr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-FeatureComplex enough to require an in depth planning process and actual budgeted, scheduled work.Resolution-DuplicateThere's another issue on the tracker that's pretty much the same thing.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions