Hebrew kerning interacts badly with text anchors

Bug #1170785 reported by David Mathog
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
In Progress
Medium
David Mathog

Bug Description

Most likely this applies to all R->L languages.

In the attached kerning example in English a variety of x,y kerns were applied. The left justified paragraph was constructed, and then the other ones were constructed from it by changing the text-anchor via the GUI (LJ ->CJ or RJ). All of these work as expected, so that the kerned lines still change justification properly. Both the SVG and a screen shot will be posted.

Not so for Hebrew. While Hebrew anchor works more or less properly, except for bug 1169348, it interacts terribly with kerning. The Hebrew kerning example is mostly like the English one, except the RJ version was constructed first. Mixing languages is another quagmire so the x,y kerning values were coded using Hebrew letters, see the table at bottom. With Hebrew changing the anchor RJ->LJ or CJ screws up the alignment badly whenever there is kerning present. IBoth the SVG and a screen shot will be posted.

If I had to guess what was going on it would be that the code involved is not taking into account the issue that dx for kerning "in the direction of the text" has the opposite sign for R->L languages.

Note that Inkscape is not alone in having Hebrew problems, Firefox for instance, inverts the order of the glyphs in the hebrew SVG examples.

Tags: text
Revision history for this message
David Mathog (mathog) wrote :
Revision history for this message
David Mathog (mathog) wrote :
Revision history for this message
David Mathog (mathog) wrote :
Revision history for this message
David Mathog (mathog) wrote :
Revision history for this message
David Mathog (mathog) wrote :

Regarding the screen shot of the Hebrew kerning example...

 The top row of text boxes include Hebrew text without kerning. The RJ one was constructed first, then the other two were made by changing the text anchor with the GUI (-> CJ or LJ). There is a very slight shift with respect to the bounding box, but overall this was the correct outcome.

The second row of text boxes was the same test as above, but with text which includes kerning. Changing the text-anchor results in the text not falling in the correct location with respect to the bounding box.

Revision history for this message
David Mathog (mathog) wrote :

Also, if one examines the SVG in the Hebrew example for one of the LJ paragraphs the "x" value is the same for all <tspan>. So the SVG appears to encode a properly justified paragraph, it just does not display that way.

Revision history for this message
David Mathog (mathog) wrote :

The problem is in Layout-TNG-Compute.cpp, where kerning was implicitly assumed to be LTR. There are several other
unrelated changes in my version of that file at the moment so a patch would be confusing. However, the change to fix this
is easy, In _measureUnbrokenSpan change this:

        if (span->start.iter_span->dx._set && span->start.char_byte == 0){
            span->width += span->start.iter_span->dx.computed;

to this:

        if (span->start.iter_span->dx._set && span->start.char_byte == 0){
            if(para.direction == RIGHT_TO_LEFT){ span->width -= span->start.iter_span->dx.computed; }
            else { span->width += span->start.iter_span->dx.computed; }

Revision history for this message
David Mathog (mathog) wrote :

The kerning example after the fix of the previous post is applied.

Note I am not at all convinced that the fix will work in the general cases. It will certainly work for when the paragraph is all R->L or all L->R, but heaven only knows what will happen if there is kerning in an English span of a mostly Hebrew paragraph, or vice versa.

Revision history for this message
jazzynico (jazzynico) wrote :

Issue reproduced on Windows XP, Inkscape trunk revision 12387.

Patch tested successfully with the SVG files provided comments #3 and #4.

Changed in inkscape:
assignee: nobody → David Mathog (mathog)
importance: Undecided → Medium
status: New → In Progress
tags: added: text
Revision history for this message
jazzynico (jazzynico) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.