Problem with TRichViewEdit and BiDiMode
-
- Posts: 148
- Joined: Wed Dec 07, 2005 2:02 pm
- Contact:
Problem with TRichViewEdit and BiDiMode
A user who is using a TrueType Hebrew font (only chars 0-255, no Unicode) sent me this to illustrate the problem. I have confirmed that the control is set to BiDiMode = rvbdRightToLeft using this command:
QMemo.Clear;
QMemo.BiDiMode := rvbdRightToLeft;
Note that SOMETHING happens because of the odd behavior of the cursor. He's using a regular Arial font for this:
It does the following. If I type “My name is Ingo” then the following happens:
1) I type “My” and press space. It starts on the LEFT border in right-to-left direction
2) After I press space the space is inserted before (left) of “My” and the cursor jumps there, too
3) If I type the next letter “n” then the cursor jumps again right to “My” [+space] and here I type “name” in conventional left-to-right order
I verified that if I time
"Now is the time"
that is exactly what I get - not the expected "emit eht si woN"
Can you help?
TIA
Dick
QMemo.Clear;
QMemo.BiDiMode := rvbdRightToLeft;
Note that SOMETHING happens because of the odd behavior of the cursor. He's using a regular Arial font for this:
It does the following. If I type “My name is Ingo” then the following happens:
1) I type “My” and press space. It starts on the LEFT border in right-to-left direction
2) After I press space the space is inserted before (left) of “My” and the cursor jumps there, too
3) If I type the next letter “n” then the cursor jumps again right to “My” [+space] and here I type “name” in conventional left-to-right order
I verified that if I time
"Now is the time"
that is exactly what I get - not the expected "emit eht si woN"
Can you help?
TIA
Dick
-
- Site Admin
- Posts: 17571
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
This is by design.
Exactly the same happens, for example, in Notepad in right-to-left mode (Right Ctrl + Right Shift).
English letters are strictly LTR characters.
Space is neutral character.
If the default mode is RTL, bidimode of neutral characters is RTL (except for the case when they are surrounded by LTR characters).
Exactly the same happens, for example, in Notepad in right-to-left mode (Right Ctrl + Right Shift).
English letters are strictly LTR characters.
Space is neutral character.
If the default mode is RTL, bidimode of neutral characters is RTL (except for the case when they are surrounded by LTR characters).
-
- Posts: 148
- Joined: Wed Dec 07, 2005 2:02 pm
- Contact:
-
- Site Admin
- Posts: 17571
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I guess you mean 'real' LTR (left to right). Sorry, no, because they are not. Spaces and other punctuation are used in RTL languages as well as LTR languages. If the default mode is RTL (right to left), it is expected that the majority of text will be Arabic or Hebrew, may be with some LTR citation.
If you do not want punctiation to be RTL by default, change BiDiMode = rvbdLeftToRight. Either for the whole document, or for the given paragraph (ParaStyles[].BiDiMode) or for the given text fragment (TextStyles[].BiDiMode).
If you use RichViewActions, they have actions for this.
PS: Even if you do not use Unicode, it does not means that text from RichView can be exported in ANSI text files lossless. It's because RichView document can contain text of different character sets (code pages). RTF export solves this problem, though.
If you do not want punctiation to be RTL by default, change BiDiMode = rvbdLeftToRight. Either for the whole document, or for the given paragraph (ParaStyles[].BiDiMode) or for the given text fragment (TextStyles[].BiDiMode).
If you use RichViewActions, they have actions for this.
PS: Even if you do not use Unicode, it does not means that text from RichView can be exported in ANSI text files lossless. It's because RichView document can contain text of different character sets (code pages). RTF export solves this problem, though.
-
- Posts: 148
- Joined: Wed Dec 07, 2005 2:02 pm
- Contact:
-
- Site Admin
- Posts: 17571
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 148
- Joined: Wed Dec 07, 2005 2:02 pm
- Contact:
-
- Site Admin
- Posts: 17571
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
TRichView uses GetCharacterPlacement function to get character classes (for ordering text items and calculating caret positions).
There is more easy to use function: GetStringTypeEx.
As for drawing text in one text item, TRichView relies on Windows text drawing functions (text is drawn as a whole string, not character by character).
There is more easy to use function: GetStringTypeEx.
As for drawing text in one text item, TRichView relies on Windows text drawing functions (text is drawn as a whole string, not character by character).
-
- Posts: 148
- Joined: Wed Dec 07, 2005 2:02 pm
- Contact: