Subject: bug#41005: problem with rendering Persian text in Emacs 27

From: Amin Bandali <[email-masked]>
Date: Fri, 24 Jul 2020 00:11:30 -0400

Eli Zaretskii <[email-masked]> writes:

>> From: Amin Bandali <[email-masked]>
>> Cc: [email-masked],  [email-masked],  [email-masked],
>>   [email-masked]
>> Date: Tue, 21 Jul 2020 22:12:19 -0400
>> 
>> >> Lastly, it might be worth mentioning that if I recall correctly, when
>> >> using xfthb with emacs-27, I observe the same issue.  Which may suggest
>> >> that perhaps the issue is related to Emacs's HarfBuzz support.
>> >
>> > But that's exactly the configuration that was fixed...
>> >
>> 
>> It is strange.  I did some more testing.  Whether with xfthb (emacs-27)
>> or ftcrhb (master), it seems like typing in Persian in *scratch* works
>> okay.  However, if I paste (yank) Persian text, e.g. from Wikipedia,
>> into *scratch*, the issue surfaces and yanked text is garbled.  Further,
>> Persian text in Gnus's article-mode and in message-mode is always
>> garbled to begin with.  It does seem like a HarfBuzz issue to me.
>> Please feel free to grab the Vazir font and test for yourself.
>
> Does this happen only with that font, or does it happen with any font
> that supports Persian?
>
> If it's only that font, then I don't think we should try solving this
> in Emacs; please report this to the font developers.
>

It appears to happen with any font supporting Persian/Arabic.  Examples
include DejaVu Sans and Noto Sans Arabic.

>
> If the problem happens with any Persian-supporting font, then please
> tell the details: which page you copy/paste from, what browser did you
> use to copy that text, detailed steps for how to reproduce in Gnus,
> etc.  This bug report described a problem that happened in different
> situation (the Emacs EWW browser), so it's hard to know what exactly
> happens in your case.
>
> Thanks.
>

Examples of pages I copied excerpts from include the front page of the
Persian Wikipedia <https://fa.wikipedia.org>, as well as the Persian
translation of GNU's homepage <https://www.gnu.org/home.fa.html>.  The
issue does not seem to be specific to a particular text, and appears to
occur when pasting any Persian text into a buffer.  As for the browser,
I tried with both GNU IceCat and Emacs's EWW; same results.  I am able
to reproduce by pasting any random Persian text into any Emacs buffer.
In the case of Gnus, simply pressing RET on the subject of an email in
gnus-summary-mode to have it displayed using gnus-article-mode shows the
Persian text in the email body as garbled.

Hope this helps.

                                 * * *

Actually, as I was about to hit send, it /just/ occurred to me to try
with -Q or -q, and in both cases I do not see this bug!  How strange!
I'll start bisecting my Emacs configuration and will report back if I
manage to find the cause.