3

I really enjoy writing bidirectional text in org-mode using Emacs as it supports the rt-to-left direction out of the box. However, when it comes to org tables alignment things become very unorganized.

I have this setup in my init.el file for correct RTL display in org file taken from this post:

(defun set-bidi-env ()
  "interactive"
  (setq bidi-paragraph-direction 'nil))
(add-hook 'org-mode-hook 'set-bidi-env)

MWE with a table in English vs Arabic to show the difference

* Tables in English (no alignment problems)

| No | Name           |             Tel |  Rate | Result |
|----+----------------+-----------------+-------+--------|
|  1 | John Doe       | +1-541-754-3010 | 34.99 | Fail   |
|  2 | Johnson Kirton | +1-541-754-3010 | 55.89 | Pass   |
|  3 | Debbie Cannon  | +1-541-754-3456 | 66.45 | Pass   |

* Tables in Arabic (problems with alignment)

| رقم | الاسم         |          الهاتف | المعدل | النتيجة |
|-----+---------------+-----------------+--------+---------|
| ١   | جون دو        | +1-541-754-3010 | ٣٤.٩٩  | فشل     |
| ٢   | جونسون كيرتون | +1-541-754-3010 | ٥٥.٨٩  | نجاح    |
| ٣   | ديبي كانون    | +1-541-754-3456 | ٦٦.٤٥  | نجاح    | 

* And this text in English after the tables

* وهذا نص باللغة العربية بعد ادراج الجداول

Screenshot to show the display enter image description here

See the alignment in the Arabic table below how it is different from that of the table in English as ugly to neat. Is there any fix to get it right?

Update

Using an Arabic monospaced font (Kawkab Mono) as kindly suggested by @Do didn't solve the problem.

Not a Duplicate

A similar issue has been reported for Japanese here, but the solutions presented there didn't help solve my problem. Changing the font to "Inconsolata-12" for example didn't change anything in the table alignment, this could be only applicable to the Japanese characters but not to Arabic ones. Neither font type nor size did improve the appearance of the alignment. The second solution in the same post, to my understanding (article in Chinese) is to try out specific pair sizes for English and the SECOND language but as I said, changing font size didn't work for me.

enter image description here

Another Monospaced Font

Trying out Droid Sans Mono did improve the appearance but it didn't solve it completely and in a larger table the bad alignment would be much worse. I ran out of ways to seek a TYPICAL monospaced Arabic font that will fix it. I wonder if such a font does exist!!

enter image description here

doctorate
  • 1,789
  • 16
  • 39
  • It seems that this problem happens because your arabic font isn't monospace, and org expects that text is displayed with a monospace font. Consider using another font such as this one: http://makkuk.com/kawkab-mono/ –  Feb 06 '17 at 17:07
  • @DoMiNeLa10 this is to confirm that I installed the monspaced arabic font as you kindly suggested and used it in my emacs setup, yet the problem persists. – doctorate Feb 06 '17 at 17:55
  • 1
    Possible duplicate of [Japanese / CJK font settings for proper horizontal alignment](http://emacs.stackexchange.com/questions/10464/japanese-cjk-font-settings-for-proper-horizontal-alignment) – wasamasa Feb 06 '17 at 23:05
  • @wasamasa, an update has been added explaining why this question is different. – doctorate Feb 07 '17 at 16:30
  • The "Use Inconsolata-12" answers for Japanese didn't really fix Japanese either--they just happened to get close to looking right. I actually had to find a monospace Japanese font that rendered Japanese characters as the right widths, and you might need to do the same for Arabic. This part is deceptively hard because even through there are fonts that support Arabic with monospaced Latin, you'll need to look for one with *monospaced Arabic*. I know you said you did this already, so this might sound redundant, but you might want to investigate your fonts some more, because they can be deceptive. – Archenoth Feb 07 '17 at 16:39
  • @Archenoth I tried monspaced Arabic fonts but it didn't solve it. Look at the bars in the org-table they simply don't align. This should be a bug somewhere where the longest width should be calculated and applied to all cells in that particular column regardless of the character set in use. – doctorate Feb 07 '17 at 16:48
  • @doctorate Sorry, I mean problems with alignment in Org mode are often caused by fonts rendering things at the wrong widths. So I am not 100% convinced the monospaced font you tried is not to blame. (Be it the settings, or the font itself) I was thinking trying other monospaced Arabic fonts could give you some hints. I had similar issues with monospaced fonts that supported Japanese, and it wasn't until I found a font that actually had the correct widths that I realized that it wasn't org-mode's fault. – Archenoth Feb 07 '17 at 17:13
  • @Archenoth Another monospaced font was tried out but still. – doctorate Feb 08 '17 at 15:13
  • @doctorate ah, that's unfortunate. If you were to copy and paste an org table into something else (Like LibreOffice) and set it to use your font, is it still messed up? If so, that means it's likely either the font (again) or indeed Org Mode's fault, and you can likely ask about it on the Org Mode [mailing list](https://lists.gnu.org/mailman/listinfo/emacs-orgmode). If it looks fine in the other program, it is possibly Emacs itself. I have no idea what other configurations for fonts remain, but If there is none, it might be an [Emacs bug.](https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs) – Archenoth Feb 08 '17 at 16:28
  • @Archenoth this is to confirm that all mono fonts above were tried out in LibreOffice write they all look terrible too. – doctorate Feb 08 '17 at 18:39
  • @doctorate Hm, so either the tables are being output incorrectly by Org, the font still has an issue, or the issue also exists in LibreOffice. But which is it..? Unfortunately, I can't really help with that--the Org Mailing list above probably could though. (Or maybe we'll get lucky and someone else will answer here) – Archenoth Feb 08 '17 at 19:40
  • 1
    Not a solution, but at least a way to isolate the problem. Some character glyphs in Arabic combine two distinct letters into one, which takes up only one character width. There is only *one* word with such a character in your table: الاسم, which has the أ + ل being displayed (correctly) as لا. Based on your screenshot with `Droid Sans Mono`, you can see that the table columns get exactly one character off right after الاسم, and nowhere else. – Dan Feb 08 '17 at 22:13

0 Answers0