Localization/Arabic

From ArchWiki

This article describes how to set up Arabic language environment.

Applications

Shell and Terminal

Vim

  • See Vim#Bidirectional support for setting up Bidi support.
  • Since Vim does not map Arabic characters given by input method, motion commands do not work. A possible workaround is to set keymap within Vim without changing X11 keymap. This can be done set keymap=arabic, then switching between layouts via Ctrl-^, or by manually set langmap in vimrc:
set langmap=ضصثقفغعهخحجد;qwertyuiop[],شسيبل;asdfg,اتنمكط;hjkl\;',ئءؤرلا;zxcvb,ىةوزظ;nm،./,لآB,آN,'M,؟?,ِA,ٍS,لأG,أH,ـJ,،K,ًW,ُE,ٌR,لإT,إY,÷I,×O,؛P

Fonts

Check Font configuration/Examples#Arabic for setting up font configuration. Persian fonts like vazirmatn-fontsAUR also include support for Arabic letters. A list of Persian fonts can be checked from Fonts#Persian.

Multi-script fonts:

Sans-Serif:

Monospace:

Bitmap:

Naskh (~Serif):

Ruq'ah, Kufic (~Sans-Serif):

Kashida support

  • LibreOffice: automatically applied for Arabic text in "Justified" paragraphs.
  • LaTeX: by using justification = kashida option in Babel package. The following is a sample document:
\documentclass{article}

\usepackage[
	english,
	bidi=basic,
]{babel}

\babelprovide[
	import, main,
	justification = kashida,
	transforms = kashida.plain
]{arabic}
\babelfont[arabic]{rm}{FreeSerif}

\begin{document}
قِفَا نَبْكِ مِنْ ذِكْرَى حَبِيبٍ ومَنْزِلِ، بِسِقْطِ اللِّوَى بَيْنَ الدَّخُول فَحَوْمَلِ. فَتُوْضِحَ فَالمِقْراةِ لمْ يَعْفُ
رَسْمُها، لِمَا نَسَجَتْهَا مِنْ جَنُوبٍ وشَمْألِ. تَرَى بَعَرَ الأرْآمِ فِي عَرَصَاتِهَا، وَقِيْعَانِهَا كَأنَّهُ حَبُّ
فُلْفُلِ. كَأنِّي غَدَاةَ البَيْنِ يَوْمَ تَحَمَّلُوا، لَدَى سَمُرَاتِ الحَيِّ نَاقِفُ حَنْظَلِ. وُقُوْفًا بِهَا صَحْبِي عَليَّ
مَطِيَّهُمُ، يَقُوْلُوْنَ: لا تَهْلِكْ أَسًى وَتَجَمَّلِ. وإِنَّ شِفائِيَ عَبْرَةٌ مُهْرَاقَةٌ، فَهَلْ عِنْدَ رَسْمٍ دَارِسٍ مِنْ
مُعَوَّلِ؟. كَدَأْبِكَ مِنْ أُمِّ الحُوَيْرِثِ قَبْلَهَا، وَجَارَتِهَا أُمِّ الرَّبَابِ بِمَأْسَلِ. إِذَا قَامَتَا تَضَوَّعَ المِسْكُ
مِنْهُمَا، نَسِيْمَ الصَّبَا جَاءَتْ بِرَيَّا القَرَنْفُلِ. فَفَاضَتْ دُمُوْعُ العَيْنِ مِنِّي صَبَابَةً، عَلَى النَّحْرِ حَتَّى
بَلَّ دَمْعِيَ مِحْمَلِي.
\end{document}

Tips and tricks

Troubleshooting

Common issues may be solved by checking Locale#Troubleshooting and Character encoding#Troubleshooting first. For problems related to letter-shaping or text direction, check Bidi.

XKB Lam Alif problem

X keyboard layout sends Arabic ligature glyphs as a single glyph. For example, Laa+Alif ligature "لا" (U+0644, U+0627) is sent as "ﻻ" (U+FEFB), and similarly for (ﻷ، ﻵ، ﻹ). This is due to a known limitation in xkb which does not allow mapping a key to more than one character. To solve this problem, run a supported input method. The input method workaround takes advantage of Compose Sequences. For a technical reading on this, check [4]. These are confirmed to work:

For a more lightweight option, you can use Xim. Add the following to your environment variables:

XIM=none
XIM_PROGRAM=/bin/true
XIM_ARGS=
GTK_IM_MODULE=xim
QT_IM_MODULE=xim
SHORT_DESC="X compose table"

Alternatively, you can use IM config wrapper script: im-config -n xim.

Since QT-based programs do not have this issue, it is enough to add export GTK_IM_MODULE=xim to ~/.xsessionrc or ~/.xprofile. The issue is also fixed for GTK4.

Tip: If input method is used, then XCompose table offers additional Arabic letters like: گ، ڤ، چ، پ, quotes «», as well as Wikipedia:Zero-width non-joiner, by pressing the AltGr key. The default compose table is located in /usr/share/X11/xkb/symbols/ara.

Fix Arabic legibility when using Noto Fonts

If Arabic characters are rendered an in an unexpected font (e.g: Nastaliq, Urdu font, etc.), see Font configuration/Examples#Excluding Arabic script from other languages.

See also