Subject: Re: bug#28339: 25.2; Emacs shows ZWNJ character (Zero Width non-Joiner) as Space

From: Eli Zaretskii <[email-masked]>
Date: Mon, 04 Sep 2017 15:11:53 +0300

> From: Nima Aryan <[email-masked]>
> Date: Mon, 04 Sep 2017 11:43:40 +0000
> Cc: Eli Zaretskii <[email-masked]>, Kenichi Handa <[email-masked]>
> 
> It got interesting and I've found a workaround for the issue. display of ZWNJ as SPACE or any other character
> is matter of font. Different fonts uses different characters. Default Emacs font shows '[' instead of space
> which is better and more readable at least. 
> 
> The only minor problem I've seen so far is the irrelevance of displayed character (shown as ZWNJ) to the
> 'glyphless-char-display-control' for Persian alphabet. 
> 
> I've attached a screenshot which shows different behavior of display for both English and Persian at the same
> time. I execute `emacs -q` to launch default Emacs. Then I open Test.text sample attached in previous
> emails. Set the `glyphless-char-display-control` to show hex-box. It's clearly shown that The English one is
> replaced by a hex-box but the Persian one with a '[' (or SPACE). No matter what the
> 'glyphless-char-display-control' the Persian case shows same character. 
> 
> Note, To type the ZWNJ for the English text, AB, I used Persian input (A, switch keyboard layout,
> SHIFT+Space, switch back to English, B). So when I put ZWNJ between the AB it's shown as hex-box (and
> affected by 'glyphless-char-display-control' as expected) but when I type it between Persian characters it's
> shown as fixed '[' or 'SPACE' (font based) no matter what the glyphless-char dictates. 

You don't need to customize glyphless-char-display-control at all for
the correct display of ZWNJ in Persian.  I pointed to that variable
before I knew you were talking about the Persian script.  When
characters in Persian script are displayed and ZWNJ among them, Emacs
combines the ZWNJ character with neighboring characters to produce the
correct shaping, as expected by users of Persian.

On my system, ZWNJ is not visible at all among Persian text, and
that's without any customizations of glyphless-char-display-control.

It's possible that the original display was incorrect because the font
you were using for Persian characters doesn't support shaping as Emacs
expects.  In that case, finding a better font and customizing your
default fontset to use it for Persian should be the solution.