Bug 3922 - Variable word/letter spacing and full justification not supported for ATSUI-rendered text
Summary: Variable word/letter spacing and full justification not supported for ATSUI-r...
Status: VERIFIED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 412
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL:
Keywords:
: 5624 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-07-09 07:21 PDT by mitz
Modified: 2006-01-07 09:58 PST (History)
2 users (show)

See Also:


Attachments
Testcase (2.64 KB, text/html)
2005-07-09 07:22 PDT, mitz
no flags Details
work in progress (7.88 KB, patch)
2005-08-23 10:58 PDT, mitz
no flags Details | Formatted Diff | Diff
Full justification of Arabic script text vs Roman and Hebrew text (137.73 KB, image/png)
2005-11-13 08:31 PST, Ahmad
no flags Details
Support extra spacing features in the ATSUI code path (19.48 KB, patch)
2005-12-22 14:05 PST, mitz
darin: review+
Details | Formatted Diff | Diff
Full justification using Kashidas implemented in I.E 6 (Windows) compared to Webkit2006-01-06 (160.12 KB, image/jpeg)
2006-01-07 09:56 PST, Ahmad
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description mitz 2005-07-09 07:21:33 PDT
Summary: The ATSUI code path does not support the CSS word-spacing and letter-spacing properties, nor 
text justification.

To reproduce: open the testcase in Safari. Select Use ATSUI For All Text in the Debug menu and reload.

Expected: see testcase.

Actual: normal word- and letter-spacing the the three Hebrew examples; Hebrew text in the last example 
not justified. When ATSUI is used for all text, the same holds for the Roman text.
Comment 1 mitz 2005-07-09 07:22:39 PDT
Created attachment 2880 [details]
Testcase
Comment 2 mitz 2005-08-23 10:58:33 PDT
Created attachment 3539 [details]
work in progress

This patch relies on bug 3963 being fixed, and even then it is not complete.
Still needs some work on justification, highlighting in general, and to
optimize-out the layout override in the trivial case.
Comment 3 mitz 2005-11-04 08:16:45 PST
*** Bug 5624 has been marked as a duplicate of this bug. ***
Comment 4 mitz 2005-11-04 08:20:43 PST
The layout override suggested by the patch is already in place, so it should be quite easy to implement 
word-spacing and justification. Letter-spacing is slightly trickier because you don't want to add it e.g. 
before a combining mark.
Comment 5 Ahmad 2005-11-13 08:31:09 PST
Created attachment 4680 [details]
Full justification of Arabic script text vs Roman and Hebrew text
Comment 6 Ahmad 2005-11-13 08:37:18 PST
Dear Mitz;

I noticed that to illustrate the text block full justification problematic Hebrew was used. Although there 
are a lot of similarity between Hebrew and Arabic (writing direction, text alignment, mirroring) Hebrew 
differs from Arabic as Arabic script system uses cursive connections to form words. Hence when it 
comes to full justification of a block of text this must be taken into account. Roman text (and Hebrew ?) 
is justified by adjusting the white space between words (and characters) while in Arabic script (Arabic, 
Persian, Urdu, Kurdish, etc) the full justification must be attained by applying the "Kashidas" to the 
block of the text. ATSUI distributes the available white space on the line by automatically lengthening or 
shortening the kashidas, which are the extender bars stretching between some of the glyphs of a word.

Technical information on this topic is available in a document publish by Apple "Rendering Unicode 
Text With ATSUI", C HAP T E R  2 ATSUI Style and Text Layout Objects p. 64-67

I think that WebKit should use the same mechanism to full justify the Arabic script text block and NOT 
the technic which increases the white space between the word/characters as this affect the context of 
the words negatively.

Wither you are going to use ATSUI to do this or some other technic you should consider the special 
requirement of Arabic script for the best result.

Good luck


(In reply to comment #4)
> The layout override suggested by the patch is already in place, so it should be quite easy to 
implement 
> word-spacing and justification. Letter-spacing is slightly trickier because you don't want to add it 
e.g. 
> before a combining mark.

Comment 7 mitz 2005-11-13 09:49:18 PST
(In reply to comment #6)

Hi Ahmad,

I think you're right -- Kashidas should be used when fully-justifying Arabic. While the CSS3 Text Effects 
Module working draft <http://www.w3.org/TR/css3-text/> specifies Kashida behavior, CSS2.1 doesn't 
mention them explicitly, but I think that doesn't mean they should not be used.

From the little I know about how text justification works in WebCore/WebKit, I suspect that 
implementing Kashidas is highly non-trivial. Because of this, and because of possible CSS3 
connections, I would suggest having a separate bugzilla bug about Kashidas, (I guess I shouldn't have 
closed bug 5624 :-( ), and limiting bug 3922 to matching the CG code path's behavior in the ATSU code 
path.

As long as you're here, I would be very grateful if you could take a look at other RTL-, bidi- and ATSU- 
related bugs in bugzilla and see if there are any Arabic-specific issues which they overlook (especially 
the rendering bugs). In particular, any feedback regarding the proposed heuristic in bug 5166 would be 
most welcome!
Comment 8 mitz 2005-12-22 14:05:13 PST
Created attachment 5227 [details]
Support extra spacing features in the ATSUI code path
Comment 9 Darin Adler 2005-12-25 08:03:50 PST
Comment on attachment 5227 [details]
Support extra spacing features in the ATSUI code path

In this:

    ceilf((float)style->padding / numSpaces)

there's no need to cast style->padding to a float. If you divide it by a float,
then the result will be floating point without any type cast.

Patch looks good, r=me.
Comment 10 Geoffrey Garen 2005-12-29 03:27:35 PST
Landed.
Comment 11 mitz 2005-12-29 06:32:07 PST
I think the testcase (included in the patch, except for pixel result) wasn't committed.
Comment 12 Darin Adler 2005-12-29 17:29:28 PST
Geoff, please look at Mitz's comment about the test case.
Comment 13 Geoffrey Garen 2005-12-29 17:37:47 PST
Landed test case today with pixel result. Sorry for confusion.
Comment 14 Ahmad 2005-12-30 13:21:49 PST
(In reply to comment #13)
> Landed test case today with pixel result. Sorry for confusion.

Dear all;

I downloaded the latest version (v. 2005-12-30) and I have to say that I am overwhelmed with the 
result of great results you have achieved.

The problem of full justified Arabic paragraph is solved, mirroring problem is solved and even problem 
of not being able to highlight and select Arabic word within a text is solved too.


I would like to thank you all, Mitz, Darin and Geoffrey on behalf of myself and on behalf of Iranian 
Macintosh User Group, IRMUG, http://irmug.org . If I knew your private address I would send you a 
bouquet of follower to show my appreciation. 
I hope that this version of Webkit will be included in the next system update.

Happy new year to you all
Ahmad

Comment 15 Ahmad 2006-01-07 09:50:34 PST
As additional comments to full justification of Arabic script, I have to mention that this problem is 
solved not in a proper way as both me and later on Mitz has pointed out. The problem of full 
justification of Arabic was solved by insertion white space thereby "Kashidas" technology was not used 
to handle this annoying bug.
Attached is a screen capture which compares the an Arabic text block handled by MS I.E 6 (on Windows) 
and WebKit v.2005-01-06. The space between word in Webkit is marked with yellow circles.

I have to emphasize here that "Kashidas" technique is not something new for Apple engineer. In 
WorldScriptI (up to OS9), 4 different level of "Kashidas" were implemented. Those of you who works for 
Apple has access to to the C++ source code of how to implement "Kashidas" so that you know that you 
do not need to re invent the Wheel once again, Apple has the code.

Ahmad
Comment 16 Ahmad 2006-01-07 09:56:56 PST
Created attachment 5527 [details]
Full justification using Kashidas implemented in I.E 6 (Windows) compared to Webkit2006-01-06
Comment 17 mitz 2006-01-07 09:58:23 PST
Use of Kashidas is tracked by bug 6203.