| Summary: | GTK-BIDI: RTL support in Text | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Semion Chichelnitsky <semion> |
| Component: | SWT | Assignee: | Bogdan Gheorghe <gheorghe> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | baochlin, eclipse.felipe, ericwill, Lina.Kemmel, matial, peter, salexb, wajnberg, yanghang |
| Version: | 3.0 | Keywords: | triaged |
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux-GTK | ||
| Whiteboard: | stalebug | ||
| Bug Depends on: | |||
| Bug Blocks: | 207245, 333624 | ||
|
Description
Semion Chichelnitsky
It means: you need to force word wrap in order to get the trail alignment on a RTL multi-line text widget ? We have this same problem for LTR, see Bug#37530 comment #5, in there we decide not to fix the problem. We should do the same here. Yes, problem has the same reason, but in case of rtl multiline Text we need to solve it. Take into consideration, that here we need to get leading (default) alignment properly, and it is more important, that correct wrapping mode. What we suggest here is the following: rtl-oriented Text should be always in WRAP_WORD mode excluding the case, when it has explicitly assigned trail alignment. I've filed a bug against GTK for this: http://bugzilla.gnome.org/show_bug.cgi?id=120256 It might be something else we can do to fix this. According to bug#37530 I found no fix for right alignment for the single line text widget, is this a bug on Bidi as well ? Works fine for GtkEntry (Single-line text). Right alignment or trail alignment? Single line SWT Text doesn't have problem with leading (default) alignment, but it's content currently can't be aligned to trailing edge of widget (it isn't bidi problem). there are some GTK-Bugs we could contribute to have this problem fixed: http://bugzilla.gnome.org/show_bug.cgi?id=59799 http://bugzilla.gnome.org/show_bug.cgi?id=120256 http://bugzilla.gnome.org/show_bug.cgi?id=118543 Semion, this bug is fixed in GTK (the problem about forcing WRAP). The thing is: the alignment is correct on BIDI when the text in the widget is RTL. In Gtk widgets the paragraph level depends on the first wrong character in the text, when the paragraph is set to one it changes the alignment left->rigth, and the other way around too. I'm not sure we can (or should) change the native behaviour of the widget. What do you think ? (In reply to comment #7) > In Gtk widgets the paragraph level depends on the first strong character in > the text, when the paragraph is set to one it changes the alignment left->rigth, > and the other way around too. It seems that nowadays proper alignment can be set irrespective of the first strong character of the content. And for Text, it is actually set upon widget creation (gtk_entry_set_alignment / gtk_text_view_set_justification for single/multi -line widget respectively). So the original problem reported here seems to be fixed (when using GTK of an appropriate level). However, we still need to override the "auto_dir" behavior when Text#setOrientation is called (i.e. when setting a strong base direction explicitly). - But this is a subject for another bugzilla entry. The basic problem is still there:
Text mirrors or not based on the content.
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell( display , SWT.SHELL_TRIM | SWT.RIGHT_TO_LEFT);
shell.setLayout(new GridLayout(1, false));
Text text = new Text(shell, SWT.SINGLE);
text.setText("hellow world.");
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label label = new Label(shell, SWT.NONE);
label.setText("hellow world.");
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
shell.setSize(400, 200);
shell.open();
while( !shell.isDisposed() ) {
if( !display.readAndDispatch() )
display.sleep();
}
display.dispose();
}
See the alignment for the text and the label differ.
Felipe,
However, OS.gtk_entry_set_alignment and OS.gtk_text_view_set_justification now seem to work properly, so Text can be aligned as needed (if the alignment is set explicitly) without the need to force wrap mode.
The following snippet (with SWT.RIGHT style added for Text) causes the Text to be aligned to the right:
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell( display , SWT.SHELL_TRIM | SWT.RIGHT_TO_LEFT);
shell.setLayout(new GridLayout(1, false));
Text text = new Text(shell, SWT.SINGLE | SWT.RIGHT);
text.setText("hellow world.");
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label label = new Label(shell, SWT.NONE);
label.setText("hellow world.");
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
shell.setSize(400, 200);
shell.open();
while( !shell.isDisposed() ) {
if( !display.readAndDispatch() )
display.sleep();
}
display.dispose();
}
____________________________
As for base text direction, this is a separate problem which AFAICS can be only overcome by using control characters..
Fixing the alignment but not fixing the base text direction does not make sense to me. We could look into what it takes to force GTK to use the base text direction we need. If that fails, in a worse cas scenario, add the control characters ourselves so that windows and gtk have the same behaviour. This fix would conflict with the fix for 230854. Other option is to say this is a platform difference and don't do anything about it (we just have to documented it). *** Bug 333130 has been marked as a duplicate of this bug. *** Some cases that are still broken on GTK:
Label + WRAP
Text depends on the text content
On Windows all the controls in this snippet are right-aligned
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display, SWT.DIALOG_TRIM|SWT.RIGHT_TO_LEFT);
shell.setSize(500, 375);
shell.setLayout(new GridLayout());
Label l0 = new Label(shell, SWT.NULL);
l0.setText("\u0646\u0635 \u0627\u0644\u062A\u0631\u0634\u064A\u062D");
l0.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 0, 0));
Label l1 = new Label(shell, SWT.WRAP);
l1.setText("\u0646\u0635 \u0627\u0644\u062A\u0631\u0634\u064A\u062D");
l1.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 0, 0));
Label l2 = new Label(shell, SWT.NULL);
l2.setText("a \u0646\u0635 \u0627\u0644\u062A\u0631\u0634\u064A\u062D");
l2.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 0, 0));
Label l3 = new Label(shell, SWT.WRAP);
l3.setText("a \u0646\u0635 \u0627\u0644\u062A\u0631\u0634\u064A\u062D");
l3.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 0, 0));
Text t0 = new Text(shell, SWT.SINGLE);
t0.setText("\u0646\u0635 \u0627\u0644\u062A\u0631\u0634\u064A\u062D");
t0.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 0, 0));
Text t1 = new Text(shell, SWT.SINGLE | SWT.WRAP);
t1.setText("\u0646\u0635 \u0627\u0644\u062A\u0631\u0634\u064A\u062D");
t1.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 0, 0));
Text t2 = new Text(shell, SWT.SINGLE);
t2.setText("a \u0646\u0635 \u0627\u0644\u062A\u0631\u0634\u064A\u062D");
t2.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 0, 0));
Text t3 = new Text(shell, SWT.SINGLE | SWT.WRAP);
t3.setText("a \u0646\u0635 \u0627\u0644\u062A\u0631\u0634\u064A\u062D");
t3.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 0, 0));
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
(In reply to comment #11) > We could look into what it takes to force GTK to use the base text direction > we need. If that fails, in a worse cas scenario, add the control characters > ourselves so that windows and gtk have the same behaviour. This fix would > conflict with the fix for 230854. I think there is no conflict with 230854 if we delegate base direction support to application. Then an application would do the following: ..... text.addSegmentListener(new SegmentListener() { public void lineGetSegments(SegmentEvent event) { event.segments = new int[] { 0 }; }); That will cause bidi marks to be prepended to a Text: LRM for a Text with SWT.LEFT_TO_RIGHT orientation and RLM - for a Text with SWT.RIGHT_TO_LEFT orientation. As LRM and RLM have strong directionality, GTK will provide RTL base direction when the text starts with RLM, and LTR - when it starts with the LRM character. As a result, both alignment and base direction will be appropriate. Better, we can merge "external" and "internal" segments (which would be easy as the latter is always a single default segment at position 0). (In reply to comment #13) > Some cases that are still broken on GTK: > Label + WRAP > Text depends on the text content > On Windows all the controls in this snippet are right-aligned Yes, but the default alignment can be overridden if specified explicitly Previously, as I understand it, one couldn't apply non-default alignment in the WRAP_NONE mode at all. Felipe, I believe that was fixed in the course of https://bugzilla.gnome.org/show_bug.cgi?id=120256 that you opened. *** Bug 465094 has been marked as a duplicate of this bug. *** This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |