[HarfBuzz] harfbuzz.old applies x advances for rtl in the wrong direction

Khaled Hosny khaledhosny at eglug.org
Thu Jan 13 11:45:54 PST 2011


On Thu, Jan 13, 2011 at 07:27:53PM +0100, Jjgod Jiang wrote:
> On Thu, Jan 13, 2011 at 6:37 PM, Khaled Hosny <khaledhosny at eglug.org> wrote:
> > X glyph advances should always be applied from left to right regardless
> > of text direction, however HarfBuzz code used in Qt applies X advances
> > in negative if text direction is right to left which breaks Arabic
> > kerning for example.
> 
> Are you sure about "X glyph advances should always be applied
> from left to right"? Can you please point me out which part of
> OpenType spec states that? I was checking [1] but couldn't
> find it.

See:
http://www.microsoft.com/typography/otspec/gpos.htm

"X and Y values specified in OpenType fonts for placement operations are
always within the typical Cartesian coordinate system (origin at the
baseline of the left side), regardless of the writing direction."

> As a side note, harfbuzz-ng is also using the same way as
> harfbuzz, see line 1536 to 1545 in hb-ot-layout-gpos-private.hh:
> 
> 1536       if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction))
> 1537         for (j = back + 1; j < i + 1; j++) {
> 1538           pos[i].x_offset += pos[j].x_advance;
> 1539           pos[i].y_offset += pos[j].y_advance;
> 1540         }
> 1541       else
> 1542         for (j = back; j < i; j++) {
> 1543           pos[i].x_offset -= pos[j].x_advance;
> 1544           pos[i].y_offset -= pos[j].y_advance;
> 1545         }

I can't comment on this, but I just tested with FireFox 4 and got
correct kerning.

> > This have been reported against Qt:
> > http://bugreports.qt.nokia.com/browse/QTBUG-4475
> > And though the issue was closed as not being reproducible, I can still
> > reproduce it (may be Qt on Windows does not use HB?).
> 
> Qt on Windows does use HB for shaping.
> 
> > The attached screenshots show the string:
> > بربربربربربربربربر
> > حوحوحوحوحوحو
> 
> Unfortunately I can't even reproduce the "after" screenshot with the
> font installed from your link with the Mac OS X native TextEdit, see
> [2], while the result looks correct with other Arabic fonts I have
> (Geeza Pro, etc.). Could that mean the font itself has some problems?

The issue is not limited to this font, I can reproduce it with other
fonts like Arabic Typesetting from MS and many Linotype fonts. Arabic
fonts from Apple are AAT fonts, so they don't apply here (may be
TextEdit on your system is not doing OpenType at all; Apple have been
too late to the game).

Regards,
 Khaled

> 
> - Jiang
> 
> [1] http://www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.html
> [2] http://d.pr/piCx

-- 
 Khaled Hosny
 Arabic localiser and member of Arabeyes.org team
 Free font developer



More information about the HarfBuzz mailing list