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

From: Pip Cet <[email-masked]>
Date: Thu, 04 Jun 2020 08:28:24 +0000

hossein valizadeh <[email-masked]> writes:

>  And finally, please try this with the version on the master branch, where a few fixes were
>  installed lately.

I can reproduce the very similar issue described (Farsi Wikipedia entry
for Emacs), on current master. I believe I've figured it out, but I can
also debug further if required.

What happens is that font-shape-gstring is called with direction == L2R,
mis-shapes the text, then caches that version in the composition gstring
cache. The cache doesn't distinguish directions, and it's never cleared,
so this "infects" other buffers, but only if they're opened afterwards,
and only for the same words.

shr appears to force bidi-display-reordering off. Removing that let
binding from shr-insert-document avoids the problem.

We should consider adding direction to our gstrings, on master. While
we're there, let's also add script, language, and harfbuzz features to
the gstrings so we know we've captured the precise harfbuzz parameters?