Subject: Re: bug#33944: 27.0.50; harfbuzz: Noto Sans Mandaic not rendered correctly

From: Benjamin Riefenstahl <[email-masked]>
Date: Tue, 01 Jan 2019 19:34:15 +0100

Eli Zaretskii writes:
> You mean, with other fonts that support Arabic shaping the problem
> doesn't happen?

Now that you asked, I get the same problem with some words in Syriac,
like with this:

    (set-fontset-font t '(?\u0700 . ?\u07FF) "Serto Mardin 20")
    (setq bidi-paragraph-direction 'right-to-left)
    (insert "\u0718\u0726\u0720\u0713\u0717\u073F")

The characters should all be connected, but the third and fourth are not
in this case.

>> From the doc string of bidi-paragraph-direction:
>
>   If this is nil (the default), the direction of each paragraph is
>   determined by the first strong directional character of its text.
>   The values of ‘right-to-left’ and ‘left-to-right’ override that.
>   Any other value is treated as nil.
>   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Did you set it to t on purpose?  If so, can you explain why?

No, that was a mistake.  OTOH it seems that "is treated as nil" is not
true, because "t" has the same effect as "right-to-left".

> What happens if bidi-paragraph-direction is set to one of the valid
> values?

With right-to-left the same happens, with left-to-right it's good again
(same as with the default).

>> The commit that breaks this is the last one, 48776b7011 "Provide text
>> directionality and language to HarfBuzz shaper".  Before that commit it
>> works for me.
>
> Can you run Emacs under a debugger and see what value of 'dir' do we
> come up with in this snippet from ftfont.c:
>
>   hb_direction_t dir = HB_DIRECTION_INVALID;
>   if (EQ (direction, QL2R))
>     dir = HB_DIRECTION_LTR;
>   else if (EQ (direction, QR2L))
>     dir = HB_DIRECTION_RTL;
>   /* If the caller didn't provide a meaningful DIRECTION, let HarfBuzz
>      guess it.  */
>   if (dir != HB_DIRECTION_INVALID)
>     hb_buffer_set_direction (hb_buffer, dir);
>
> Do we call hb_buffer_set_direction, and if so, with what value?

With "t" or right-to-left we have dir == HB_DIRECTION_LTR, and yes we go
into that function.  With the default (nil) or left-to-right we have dir
== HB_DIRECTION_RTL and we also call that function.  Is this switched
around somewhere?

Thanks for looking into this,
benny