Upon further investigation, I realized that in my config I have used a combination of `default-frame-alist` and `set-fontset-font` that I forgot about. So here's a reproduction I hope can be useful for you. First of all the case is the same for both editable buffers and read-only ones so I'm just using a file with following content:
تست
تحقیق
به
اصالت
شرتالکو
حقیق
حقیقت
سنت
تالکو
مدرن
مدرنیزاسیون
I have tested this in three cases. Please note they are basically the same with some minor differences, but I mention them for completeness.
1- If I have not set a default font in my config, the text is rendered with broken ligatures. And if I set the font using `M-x set-frame-font` then everything is okay (even if I set it again to the default font used for Persian / Arabic text).
2- If I use something like the following in my config files:
`(add-to-list 'default-frame-alist '(font . "DejaVu Sans Mono-12"))`
on init the font is rendered broken. And if I set the font using `M-x set-frame-font` then everything is okay. Now if I set it again to DejaVu Sans Mono (the font I have used in my config file), it still shows broken text. I have to first set it to another font and then set it again to DejaVu so it renders correctly.
3- If I use the following line in my config:
`(set-frame-font "DejaVu Sans Mono-12" t t)`
on init the font is broken. And if I set the font using `M-x set-frame-font` then everything is okay (like previous cases). But I can't set it to DejaVu Sans Mono using `M-x set-frame-font` in any way. That means I first tried to change the font to something different and then back to DejaVu and still it didn't work.
I should note that I have tested this with various fonts and the result is the same. Also I have tested this in Org and Fundamental modes and the result is the same. Also I didn't add `set-fontset-font` to the mix but I supposed it's not going to make a difference.
I hope this helps, and excuse me if it's not. Thanks for your patience.