I've provided a minimal test text, written in Emacs (Test.text) and its display for Gedit (Gedit_display.png) and Emacs (Emacs_display.png). The Gedit display is the correct one. 

Best Regards,




On Mon, Sep 4, 2017 at 9:00 AM Eli Zaretskii <eliz@gnu.org> wrote:
> From: Nima Aryan <nimawebgard@gmail.com>
> Date: Sun, 03 Sep 2017 19:31:16 +0000
>
> The problem is specific (as it could be tested) to non-English Alphabet. At least Persian.
>
> I've tested the 'glyphless-char-display-control' and I can confirm that as It seems, it's working on English input
> as expected. For example choosing to set `Hex box` cause ZWNJ be replaced as hex box. Other options
> (including defaults) seems to works as expected.
>
> But the same option (on the same session) does not work as expected for Persian (and possibly other
> similar) alphabets.

Ah, that changes everything.  When Emacs displays the Persian script,
it composes the ZWNJ character with surrounding characters to provide
correct shaping.  The rules for this character composition are in
lisp/language/misc-lang.el, near the end.  I don't read Persian, but
if the resulting shaping is incorrect, please show specific examples
with characters from the Persian script, and please show screenshots
of their correct display (in some other application) vs what Emacs
produces on your system.  Then we can investigate what could possibly
be wrong with the Emacs display.

> p.s. Just as a hypothesis, BiDi most interfere here as well and causes such behavior.

I'm not sure this is the reason, but I need a clear example to
investigate.

Thanks.