Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 261270 - No support for right-to-left Styled Text on Mac OS X
Summary: No support for right-to-left Styled Text on Mac OS X
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.4.1   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.6 M4   Edit
Assignee: Felipe Heidrich CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 277449 (view as bug list)
Depends on:
Blocks: 288554
  Show dependency tree
 
Reported: 2009-01-15 16:08 EST by benson margulies CLA
Modified: 2010-05-04 11:05 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description benson margulies CLA 2009-01-15 16:08:29 EST
Build ID: M20080911-1700

Steps To Reproduce:
1. Try to call setOrientation on a StyledText widget on MacOS.
2. Observe that nothing happens.
3. Step into code and find org.eclipse.swt.internal.BiDiUtil, which stubs out all attempts at BiDi on MacOS.
4. Fail to build presentable Hebrew/Arabic app for use on MacOS.



More information:
Comment 1 Felipe Heidrich CLA 2009-01-16 10:16:19 EST
SWT.RIGHT_TO_LEFT is used in SWT to mirror a control.
Mac, as far as I know, doesn't support mirrored UI.
Comment 2 benson margulies CLA 2009-01-16 12:04:45 EST
Mac applications in general support writing direction. I'm not asking for MIRRORING, just RIGHT_TO_LEFT and LEFT_TO_WRITE. Even the TextEdit application has it.

Comment 3 Felipe Heidrich CLA 2009-01-16 12:18:40 EST
I know.
I'm just telling you what RIGHT_TO_LEFT means in SWT.
On platforms where RIGHT_TO_LEFT is implemented you get mirrored and RTL writing direction.
We don't have a API that only changes the writing direction.
Comment 4 benson margulies CLA 2009-01-16 12:47:46 EST
Hmm.

Here's what I thought I was asking for with SWT.RIGHT_TO_LEFT in StyledText:

1) Initial Unicode Bidi context RTL.
2) Ragged-right text.

This does involve any mirroring of coordinates, of course.

Am I missing some existing way to achieve this state of affairs in a StyledText control?

I could fake #1 with a RTL forcing character, but it's going to be painful to deal with the cursor implications of that, and I suppose that #2 is just plain SWT.RIGHT?



Comment 5 Felipe Heidrich CLA 2009-01-16 14:10:04 EST
see StyledText#addBidiSegmentListener
try to set the orientation to SWT.RIGHT_TO_LEFT and use the entire line as one big segnment. 

for #2 try SWT.RIGHT, note that only works when wrap is on.

Let me know if it works.
Comment 6 benson margulies CLA 2009-01-16 15:27:50 EST
I don't see how your prescription can work. In StyledText.setOrientation, there are no side effects that I can see if BidiUtil.setOrientation returns false, which it does.

This seems odd, considering the following function:


/**
 * Temporary until SWT provides this
 */
boolean isBidi() {
	return IS_GTK || IS_CARBON || BidiUtil.isBidiPlatform() || isMirrored;
}

The code in setOrientation sort of seems to be trying to distinguish isMirrored from RIGHT_TO_LEFT, but all the other style management code agrees with your analysis. e.g.:

public int getStyle() {
	int style = super.getStyle();
	style &= ~(SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT | SWT.MIRRORED);
	if (isMirrored()) {
		style |= SWT.RIGHT_TO_LEFT | SWT.MIRRORED;
	} else {
		style |= SWT.LEFT_TO_RIGHT;
	}
	return style;
}


I'm not seeing how I can make a BiDiSegmentListener do what I need here. I don't want to disassemble the line into separately reordered segments, I just want to change the 'outermost context' to be RTL. There isn't an 'orientation' in the event object, at least not in 3.4.


I'm a bit surprised to hear that RIGHT is ignore without WRAP. Even without BiDi, why not support ragged-left text when not wrapping? People do use it for some things. I could turn on WRAP, I suppose, it won't hurt anything much.

Comment 7 Felipe Heidrich CLA 2009-01-16 16:27:12 EST
i'm sorry, you are right. I should have tested the idea myself before posting it. I'm busy today.

The way bidi segment is implemented it would insert the bidi control character for you. I afraid you will have to surrond your text with RTO and PDF yourself.

see 135638 also (about alignment problems)
Comment 8 benson margulies CLA 2009-01-18 13:46:33 EST
SWT.RIGHT|SWT.WRAP plus RLE/PDO is doing the job for me as of now. Since I'm currently read-only, it's not too awful. It would be pretty hard to keep this right in an editor with modifications happening.

The question is, where do 'we' go from here? I quote 'we' because I'm not sure that I qualify here to have an opinion, let alone to submit a credible patch.

On good old Windows, mirroring is completely distinct from text directionality. Mirroring has a special API, it is not for the faint of hear. Mirroring only effects coordinates, and directionality does nothing except alignment plus bidi context.

In fact, Windows goes to a lot of trouble to avoid unwanted 'Leonardo daVinci' behavior with mirroring in GDI (Actually writing text backwards).

Given that StyledText does not deal in coordinates, I wonder if the hard link between the two could be broken without horrible incompatibility? 

Alternatively, would it make sense to leave Orientation alone as referring to mirroring, and add a new style that asks for RTL initial context? This would have to be consistently handled in ordinary Text boxes.

As a final cheap suggestion, a new interface on the Bidi listener that would allow the listener to specify the initial directionality for each identified segment? I'd make a patch for that if you felt that it would have some reasonable probability of being smiled upon.




Comment 9 Felipe Heidrich CLA 2009-01-19 10:30:04 EST
(In reply to comment #8)
> On good old Windows, mirroring is completely distinct from text directionality.

Not true. Try setting WS_EX_LAYOUTRTL in control, a button or a label for example. Notice how the default paragraph direction is also changed right-to-left. As far as I know, you can't separate mirroring and text direction in win32 (without bidi control chars that is).

Worse, try to draw text in a window with WS_EX_LAYOUTRTL set using a hDC without LAYOUT_RTL set. The other way around is also problematic. 
See Bug 64413

Comment 10 benson margulies CLA 2009-01-19 11:12:54 EST
It's been over a year since  I was immersed in SetProcessDefaultLayout. If the LAYOUTRTL style does the same thing that it does, then I'm just wrong. I'm used to thinking about mirrored coordinate management as distinct from RTL text direction.


Which leaves the question: what model of RTL could SWT have that can map out to Mac?

Comment 11 Felipe Heidrich CLA 2009-01-19 16:43:02 EST
(In reply to comment #10)
> Which leaves the question: what model of RTL could SWT have that can map out to
> Mac?

On Mac, our current requeriment is to handle bidi text. The default paragraph direction on Mac is always left-to-right.

I think what you need is Bug 64413, new API to set only the default paragrah direction (no mirroring with it). It was long time ago, but from what I remember it was quite hard to implement it on all platforms.
Comment 12 Felipe Heidrich CLA 2009-05-22 10:07:51 EDT
*** Bug 277449 has been marked as a duplicate of this bug. ***
Comment 13 Felipe Heidrich CLA 2009-12-04 15:49:25 EST
Fixed in HEAD > 20091204

RIGHT_TO_LEFT on mac only changes the default paragraph level to 1, but it does not mirror the control.
Comment 14 Markus Keller CLA 2009-12-09 08:27:50 EST
In I20091207-1800/Cocoa, I can see the swapped orientation when I pass RIGHT_TO_LEFT in the constructor of StyledText, but setOrientation(..) doesn't change anything (with both directions).
Comment 15 Felipe Heidrich CLA 2009-12-09 09:06:42 EST
(In reply to comment #14)
> but setOrientation(..) doesn't change anything (with both directions).

setOrientation only works on windows (this holds true for StyledText/Text/Combo).