home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 2
Feature Requests
Adding support for Right-to-left languages (Hebrew, Arabic...)
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="morpheus_xx" data-source="post: 1106747" data-attributes="member: 48495"><p>I made many tests today, based on proper arranging of character order for rendering. This gives the same result as when we render the glyphs in different order, so I sort the string like it has to be rendered.</p><p></p><p>My latest algorithm is the shortes and most efficient yet, but still lacks minor details (see red marked places) in screenshot.</p><p>[CODE=C#]</p><p> public static string ReverseRTLCharsForRendering(string text)</p><p> {</p><p> StringBuilder sb = new StringBuilder(text.Length);</p><p></p><p> int caretPosition = 0;</p><p> for (int index = 0; index < text.Length; index++)</p><p> {</p><p> var codepoint = char.ConvertToUtf32(text, index);</p><p> bool isRTL = _characterTable.IsRandALCat(codepoint);</p><p> char c = text[index];</p><p> sb.Insert(caretPosition, c);</p><p> if (!isRTL && !IsWhiteSpaceFollowedByRTL(text, index))</p><p> caretPosition++;</p><p> }</p><p> return sb.ToString();</p><p> }</p><p></p><p> static bool IsWhiteSpaceFollowedByRTL(string text, int index)</p><p> {</p><p> for (int i = index; i < text.Length; i++)</p><p> {</p><p> var codepoint = char.ConvertToUtf32(text, i);</p><p> char c = text[i];</p><p> if (char.IsWhiteSpace(c))</p><p> continue;</p><p> return _characterTable.IsRandALCat(codepoint);</p><p> }</p><p> return false;</p><p> }[/CODE]</p><p>In summary, single direction texts are rendering properly, but mixed direction have small issues at start or end (and around whitespaces). But anyway a good progress.</p><p></p><p>For completeness, this is the check if the selected culture is RTL:</p><p>[CODE=C#]bool cultureIsRTL = ServiceRegistration.Get<ILocalization>().CurrentCulture.TextInfo.IsRightToLeft;[/CODE]</p><p></p><p>[ATTACH=full]156831[/ATTACH]</p></blockquote><p></p>
[QUOTE="morpheus_xx, post: 1106747, member: 48495"] I made many tests today, based on proper arranging of character order for rendering. This gives the same result as when we render the glyphs in different order, so I sort the string like it has to be rendered. My latest algorithm is the shortes and most efficient yet, but still lacks minor details (see red marked places) in screenshot. [CODE=C#] public static string ReverseRTLCharsForRendering(string text) { StringBuilder sb = new StringBuilder(text.Length); int caretPosition = 0; for (int index = 0; index < text.Length; index++) { var codepoint = char.ConvertToUtf32(text, index); bool isRTL = _characterTable.IsRandALCat(codepoint); char c = text[index]; sb.Insert(caretPosition, c); if (!isRTL && !IsWhiteSpaceFollowedByRTL(text, index)) caretPosition++; } return sb.ToString(); } static bool IsWhiteSpaceFollowedByRTL(string text, int index) { for (int i = index; i < text.Length; i++) { var codepoint = char.ConvertToUtf32(text, i); char c = text[i]; if (char.IsWhiteSpace(c)) continue; return _characterTable.IsRandALCat(codepoint); } return false; }[/CODE] In summary, single direction texts are rendering properly, but mixed direction have small issues at start or end (and around whitespaces). But anyway a good progress. For completeness, this is the check if the selected culture is RTL: [CODE=C#]bool cultureIsRTL = ServiceRegistration.Get<ILocalization>().CurrentCulture.TextInfo.IsRightToLeft;[/CODE] [ATTACH=full]156831[/ATTACH] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Feature Requests
Adding support for Right-to-left languages (Hebrew, Arabic...)
Contact us
RSS
Top
Bottom