Closed Bug 96305 Opened 21 years ago Closed 20 years ago

[BiDi] Right-to-left Hebrew does not work on Mac

Categories

(Core :: Layout: Text and Fonts, defect)

PowerPC
Mac System 9.x
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla0.9.8

People

(Reporter: mozila.bugzilla, Assigned: ftang)

References

()

Details

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Macintosh; U; PPC; en-US; rv:0.9.3+) Gecko/20010821
BuildID:    2001082108

When viewing *any* logical Hebrew page, text renders left-to-right, so, in
effect, only visual Hebrew is supported. Picking ISO-8859-8-I, Windows-1255 or
Visual Hebrew makes no difference. I tried changing my default script from
Hebrew to Roman. I tried restarting without WorldScript I at all. Neither helps.


Reproducible: Always
Steps to Reproduce:
1.View any logical Hebrew page on the web

Actual Results:  It was rendered left-to-right

Expected Results:  Render it bidirectionally.

*** This bug has been marked as a duplicate of 80577 ***
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → DUPLICATE
This bug is NOT a duplicate of bug 80577. The other bug complained that, although each different word is displayed correctly, their order is reversed. The current bug informs that, in fact, there is no BiDi at all on the Mac. The Individual words are displayed left-to-right.
Status: RESOLVED → UNCONFIRMED
Resolution: DUPLICATE → ---
No. that bug says that bidi doesn't work on macos. the fact that the summary or 
individual cases don't exactly match doesn't mean that the spirit isn't the 
same.
I checked the attached documents on bug 80577, and they describe a different 
situation. They describe a situation in which the BiDi algorithm has been 
applied to the text, but produces bad results. In my situation, the BiDi 
algorithm is not applied to the text at all.
As an experienced programmer, this suggests to me that these are two different 
bugs. Perhaps on MacOS 8.5 the BiDi algorithm is enabled, and for some reason 
it was completely disabled for MacOS 9.0. You can see that from the comments 
in that bug as well.
With regard to what might have been enabled before or not: I know for sure that
that in earlier versions of Mozilla it was possible to display numbers
RightToLeft by adding the RightToLeft entities/marks. Example in utf code:
?ÄÆ13579?Ĩ. At the same time the Hebrew text went the wrong way, so it was a
bit strange. But this RTL-ing of number no longer works, as much as I have found
out. It suggests to me that Herouth might be right: 80577 is not the same bug.
Herouth, can you provide a URL and instructions on how this bug can be verified? I 
would like to get this off the unconfirmed list, but I can't read Hebrew so I don't know 
right from wrong.
The page <http://homepage.mac.com/sillijdfiu81j/simple_machebrew_sample.html>
have been updated to clarify that it also relates to this bug report. It now
also features a picture showing how the page looks like in Mac Mozilla (in case
you only have a PC).
I can confirm the behavior described by Leif's URL. Whether this is a duplicate
or not will have to be decided later.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Mass-move all BiDi Hebrew and Arabic qa to me, zach@zachlipton.com. 
Thank you Gilad for your service to this component, and best of luck to you 
in the future.

Sholom. 
QA Contact: giladehven → zach
So, what is going on with this bug? Mozilla isn't worth much if it can't 
display logical web sites...
Leif Halvard Silli:

Can you please update your webpage now that x-mac-hebrew is working so 
that we can see the reversing/ordering problem?

Thank you.
Since it seems thet Mr. Silli is not responding to Mr. Kaply's request, I hereby suggest a simple HTML file in the ISO-8859-8-i encoding, which shows a Hebrew sentence, and the GIF of how it should look like.

http://www.herouth.f2s.com/hebrew.html
*** Bug 110766 has been marked as a duplicate of this bug. ***
It seems that on mac which is a Bidi System ,
The functions FormatUnicodeText (used in nsTextFrame::PaintUnicodeText) , is reversing 
the text => double reversing .
tricking the below code might solve the problem on mac.

anyway , i see to options.
Plan A:
----------
we should let the mac use its own Bidi capabilities.
and Reverse text only when there is a need.

++>  if text is Right-To-Left & Logical & OS 9 , then 
++>  	aIsOddLevel++;

On OS X , Quickdraw doesnt support Bidi , so Hebrew Rendering
is OK . also the bug 86253 , doesn't appear on OS X ( but it might be back when
Hebrew will be fixed on OS X).

Plan B:
--------
for Bidi/Unicode Drawing , use ATSUI to draw the text . 
with ATSUI we can disable OS Bidi .

From mozilla/gfx/mac/ :
nsUnicodeRenderingToolkit::DrawString()  should call mATSUIToolkit.DrawString()
instead of nsUnicodeRenderingToolkit::DrawTextSegment() 

for example see : nsUnicodeRenderingToolkit :: ATSUIFallbackDrawChar

Nissan.
-----------------------------------
/mozilla/layout/base/src/nsBidiPresUtils.cpp

nsBidiPresUtils::FormatUnicodeText (...)  
 inside...
	if (aIsBidiSystem) {
	    if ( (CHARTYPE_IS_RTL(aCharType)) ^ (aIsOddLevel) )
	      doReverse = PR_TRUE;
	  }
	}
later...
	if (doReverse) {
	      rv = mBidiEngine->WriteReverse(aText, aTextLength, buffer,
	                    NSBIDI_REMOVE_BIDI_CONTROLS | NSBIDI_DO_MIRRORING, &newLen);
	      if (NS_SUCCEEDED(rv) ) {
	        aTextLength = newLen;
	        nsCRT::memcpy(aText, buffer, aTextLength * sizeof(PRUnichar) );
	      }
	    }
Below is a part of an email a gollege of mine sent mkaply. I think it might 
help (re a similar bug):

=== start email ===

Someone pointed me to this bug report in bugzilla and I have a possible 
solution to the problems mentioned:
You wrote:
>
> From what we know, Bidi support on the Mac is a tricky because there
> is no way to tell the OS NOT to do anything with Arabic/Hebrew text
> that it is given - it always tries to reverse/shape it.
>

There is a way, actually. There are spacial flags to control this 
behaviour you can access them through Get/SetScriptVariable
with the smScriptFlags selector
The flags are
smsfForms - turn the contextual forms on and off
smsfLigatures - turn off ligature formation
smsfReverse - turn off the reordering (this flag is used for line 
breaking as well (you need to switch reordering off for pixelToChar to 
give you the correct results))
There is complete documentation in apple's site (I guess you can figure 
out the URL... :->).
=== end email ===

Thanks Shoshannah ,

Here is an example for disabling reordering of RTL text :
	long		aSaveFlags,aFlags;
	short	aScriptCode;
	bool		isReverse;
   	int		aHebrewFont  = 18432;	// Arial Hebrew
		
	aScriptCode = FontToScript(aHebrewFont);
	TextFont(aHebrewFont);
	
	aSaveFlags = aFlags = GetScriptVariable (aScriptCode,smScriptFlags);
	
	isReverse = (aFlags>>smsfReverse) & 1;
	
	if (isReverse)	{
		aFlags &= ~(1 << smsfReverse);
		SetScriptVariable(aScriptCode,smScriptFlags,aFlags);
	}
	
	::MoveTo(100,100);
	::DrawString("\pעברית");
	
	if (isReverse)	SetScriptVariable(aScriptCode,smScriptFlags,aSaveFlags);
	
Blocks: 115710
We probably need to fix bug 116976 and bug 116982 first before fixing others. On
MacOS X w/o Hebrew script support (but have Hebrew font), fixing bug 116976 and
116982 make it work. We may need to twick the script flag for MacOS 9.
Assignee: mkaply → ftang
Depends on: 116976, 116982
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9.8
I believe the following three patch should fix most mac os hewbrew problem

big endian issue in nsFrame.cpp
see latest patch in http://bugzilla.mozilla.org/show_bug.cgi?id=116976

big endian issue in nsBidiImp.cpp 
http://bugzilla.mozilla.org/attachment.cgi?id=62917&action=view

turn off hebrew reordering and do not report hint on mac gfx
http://bugzilla.mozilla.org/attachment.cgi?id=62920&action=view
Great moves .
but turnning off hebrew reordering has system wide effect under OS 9.
screen updates of other applications at background can be hurt .

i dont see where you are enabling it again ( this is vital )

lets say you enabled hebrew in the destructor of nsUnicodeRenderingToolkit
is it possible that WaitNextEvent will be called while hebrew is disabled ?
if so , it will be better to disable hebrew just before the drawing , and enable it
a right after.
>Great moves .
>but turnning off hebrew reordering has system wide effect under OS 9.
>screen updates of other applications at background can be hurt .
>
>i dont see where you are enabling it again ( this is vital )
Well... then we can do what we did to Arabic. Complete remove the QD code path
and use ATSUI only. This will make it work the same way as MacOS X.
1.Can you point me to the place where Hebrew and Arabcic are branched to different drawing 
method ?
2. ATSUI is bidi support by default . Are you going to add Bidi Directions format chars to disable reordering ?
>1.Can you point me to the place where Hebrew and Arabcic are branched to
different drawing 
method ?

several places. smontague can show you.
The good thing is once we take this approach. The code path is similar to
non-BIDI window and simplified the bug fixing.

>2. ATSUI is bidi support by default . Are you going to add Bidi Directions
format chars to disable reordering ?

I know, but we are not using ATSUI as main stream drawing routines on Mac yet.
(dur to worst case performance issue)

we currently use ATSUI as fallback drawing method draw one character at a time
from left to right. 
this should be fixed right now.
Status: ASSIGNED → RESOLVED
Closed: 21 years ago20 years ago
Resolution: --- → FIXED
Blocks: 104060
No longer blocks: 104060
Component: Layout: BiDi Hebrew & Arabic → Layout: Text
QA Contact: zach → layout.fonts-and-text
You need to log in before you can comment on or make changes to this bug.