Document from right to left.
Document from right to left.
How can I create a document that is read from right to left, instead of the traditional left to right format, in RichView?
-
- Site Admin
- Posts: 17562
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Document from right to left.
Assign TRichView.BiDiMode = rvbdRightToLeft.
You can also assign BiDiMode of paragraphs of text fragments (using RVStyle.ParaStyles[].BiDiMode and RVStyle.TextStyles.BiDiMode). RichViewActions have actions to apply BiDiMode to selected paragraphs and text.
You can also assign BiDiMode of paragraphs of text fragments (using RVStyle.ParaStyles[].BiDiMode and RVStyle.TextStyles.BiDiMode). RichViewActions have actions to apply BiDiMode to selected paragraphs and text.
Re: Document from right to left.
Hi, I downloaded the trial version and installed it on Delphi 12. I set all of TRichViewEdit.BidiMode and RVStyle.ParaStyles[].BiDiMode and RVStyle.TextStyles.BiDiMode to rvbdRightToLeft, But it is still left to right. How to fix this?Sergey Tkachenko wrote: ↑Mon Jul 08, 2024 10:19 am Assign TRichView.BiDiMode = rvbdRightToLeft.
You can also assign BiDiMode of paragraphs of text fragments (using RVStyle.ParaStyles[].BiDiMode and RVStyle.TextStyles.BiDiMode). RichViewActions have actions to apply BiDiMode to selected paragraphs and text.
-
- Site Admin
- Posts: 17562
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Document from right to left.
Please send me a simple project reproducing the problem (to email richviewgmailcom)
Re: Document from right to left.
I sended the email.Sergey Tkachenko wrote: ↑Sat Nov 23, 2024 6:31 pm Please send me a simple project reproducing the problem (to email richviewgmailcom)
-
- Site Admin
- Posts: 17562
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Document from right to left.
Sorry for the delay.
In your example, everything works as expected.
1. The default BiDi mode (LTR or RTL) is applied to characters that do not have strong directional properties (i.e., to punctuation and spaces). Western characters are always displayed LRT, Arabic characters are always displayed RTL. Try typing any English text in your demo. You can see, the last space is always displayed to the left of the text, because the default direction is RTL. English characters are still displayed LTR (because that have a strong LTR property) as well as spaces between them (because spaces between LTR characters are considered LTR).
2. You can also see, since the default direction in this document is RTL, the LEFT and RIGHT arrow keys work in RTL mode: LEFT key moves to the next character, RIGHT key moves to the previous character. You can see it both in English and in Arabic text.
3. To make your HTML loading code work on my (non-Arabic) Windows, I modified it to load HTML in UTF-8 encoding:
(see the new parameters in TStringStream.Create and RichViewEdit1.LoadHTMLFromStream.
4. TRichView does not support loading DIR attribute from HTML (it will be implemented in the next update), so it is ignored. All paragraphs are loaded with default BiDi property (rvbdUnspecified). However, RichViewEdit1.BidiMode = rvbdRightToLeft, so the default direction in all paragraphs is RTL.
5. Arabic text from your HTML is displayed RTL.
In your example, everything works as expected.
1. The default BiDi mode (LTR or RTL) is applied to characters that do not have strong directional properties (i.e., to punctuation and spaces). Western characters are always displayed LRT, Arabic characters are always displayed RTL. Try typing any English text in your demo. You can see, the last space is always displayed to the left of the text, because the default direction is RTL. English characters are still displayed LTR (because that have a strong LTR property) as well as spaces between them (because spaces between LTR characters are considered LTR).
2. You can also see, since the default direction in this document is RTL, the LEFT and RIGHT arrow keys work in RTL mode: LEFT key moves to the next character, RIGHT key moves to the previous character. You can see it both in English and in Arabic text.
3. To make your HTML loading code work on my (non-Arabic) Windows, I modified it to load HTML in UTF-8 encoding:
Code: Select all
strStream := TStringStream.Create(Memo1.Text, TEncoding.UTF8);
RichViewEdit1.Clear;
RichViewEdit1.DeleteUnusedStyles(true, true, true);
RichViewEdit1.LoadHTMLFromStream(TStream(strStream), '', CP_UTF8);
RichViewEdit1.Format;
4. TRichView does not support loading DIR attribute from HTML (it will be implemented in the next update), so it is ignored. All paragraphs are loaded with default BiDi property (rvbdUnspecified). However, RichViewEdit1.BidiMode = rvbdRightToLeft, so the default direction in all paragraphs is RTL.
5. Arabic text from your HTML is displayed RTL.