dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.04k stars 1.17k forks source link

RTL Maldivian/Dhivehi (Thaana) text is not displayed correctly in WPF textboxes #4074

Open mtodkari opened 3 years ago

mtodkari commented 3 years ago

Issue is reproducible with certain right-to-left languages, like Dhivehi/Thaana and Uyghur/Uighur Arabic, but not others like Hebrew and Arabic.

Actual behavior: Reversed text (incorrect) image

Expected behavior: Correct Text: image

Minimal repro:

  1. In a simple WPF application, copy the text ތާނަ from Wiki page,
  2. Observe that Thaana script is shown reversed image
miloush commented 3 years ago

When the directionality of the TextBox is set to RTL, it renders as expected (although that is not required for Arabic).

There is also a list of supported scripts by WPF, see https://docs.microsoft.com/en-us/dotnet/desktop/wpf/advanced/globalization-for-wpf?view=netframeworkdesktop-4.8#international-text.

mtodkari commented 3 years ago

@miloush thank you for your response. We cannot use FlowDirection="RighToLeft" because that affects the display direction in English as well. Arabic and Hebrew RTL are correctly handled by WPF and do not need any special formatting. Thaana should be handled similarly too.

https://github.com/dotnet/wpf/blob/bc968b3127f12031534e2e0674278314ec558744/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/FixedTextBuilder.cs#L1135 Maybe Thaana just needs to be added to _IsRTL.