Safe solution fix issues RTL Text in Windows Terminal #23242

Closed
opened 2026-01-31 08:36:24 +00:00 by claunia · 2 comments
Owner

Originally created by @n-mr on GitHub (May 9, 2025).

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

Originally created by @n-mr on GitHub (May 9, 2025). ### 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_
claunia added the Issue-FeatureResolution-Duplicate labels 2026-01-31 08:36:25 +00:00
Author
Owner

@DHowett commented on GitHub (May 9, 2025):

Thanks for the recommendation!

We are not using DWrite TextLayouts. This code is not applicable.

This is, broadly, a /duplicate of #538.

@DHowett commented on GitHub (May 9, 2025): Thanks for the recommendation! We are not using DWrite TextLayouts. This code is not applicable. This is, broadly, a /duplicate of #538.
Author
Owner

@microsoft-github-policy-service[bot] commented on GitHub (May 9, 2025):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@microsoft-github-policy-service[bot] commented on GitHub (May 9, 2025): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report! <!-- Policy app identification https://img.shields.io/static/v1?label=PullRequestIssueManagement. -->
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23242